解决jQuery AJAX请求,数据中的数组无法正常映射到Java对象中的问题
问题描述
java.lang.NumberFormatException: For input string: ""
解决方法
加上traditional : true
加上后请求参数正常:
如不加上,请求参数会变成数组
https://stackoverflow.com/questions/25134795/pass-array-into-spring-mvc-by-ajax
解决Tomcat控制台日志乱码的问题
解决方法
修改配置问题件
conf/logging.properties
tomcat8.0 加上 java.util.logging.ConsoleHandler.encoding = UTF-8
tomcat8.5 后为默认
IDEA设置console的字符编码
解决Tomcat或Jetty中间件不扫描WebApplicationInitializer的问题
解决方法
添加3.1版本的web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
解决Spring注入报错org.springframework.beans.factory.BeanNotOfRequiredTypeException的问题
问题描述
注入如下bean
报错
org.springframework.beans.factory.BeanNotOfRequiredTypeException : Bean named 'defaultStartProcessOper' must be of type [com.todaytech.pwp.workflow.facade.DefaultStartProcessOper], but was actually of type [$Proxy61]
注入的bean如下
解决方法
将注入的属性的类,改为接口,不是具体的类
Spring动态代理的实现方式决定如果要注入的类是实现了接口的,注入的时候只能注入到接口,不可注入到具体的类
解决Spring MVC报错 javax.servlet.ServletException Could not resolve view with name xxx in servlet with name spring的问题
问题描述
javax.servlet.ServletException: Could not resolve view with name 'xxx' in servlet with name 'spring'
问题原因
SpringMVC认为是需要请求视图页面
解决方法
将对应的请求方法加上@ResponseBody
可以注明并不是请求页面
解决Spring MVC 响应返回中文内容变成问号的问题
解决方法
@ResponseBody 解决方法:
DispatcherServlet XML应用上下文配置
<bean id="utf8Charset" class="java.nio.charset.Charset" factory-method="forName">
<constructor-arg value="UTF-8"/>
</bean>
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
...
解决Spring Cloud bootstrap.yml配置不生效的问题
问题原因
Spring Boot默认不支持bootstrap配置文件,只支持application配置文件,需要引入spring-cloud-context后才可以生效
解决方法
引入spring-cloud-context
IDEA在配置文件未生效时的图标
IDEA在配置生效后的图标
解决Spring Cloud Gateway路由报错 java.net.UnknownHostException的问题
问题描述
报错信息
java.net.UnknownHostException: renren-fast
问题原因
路由配置uri为http://renren-fast
解决方法
路由配置uri为lb://renren-fast
332 post articles, 34 pages.