bug1:使用struts2框架时,org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 显示该架包不存在
解决办法:此架包在struct2 2.5版本前有,但是2.5以后就修改了,架包的位置,应该为
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
bug2:Caused by: java.lang.ClassNotFoundException: org.thymeleaf.spring5.view.ThymeleafViewResolver
解决办法:因为 parent 中已经引入的版本 当中已经包含了thymeleaf 的版本,不需要再添加依赖
bug3:The field file exceeds its maximum permitted size of 1048576 bytes
解决办法:Spring Boot文档说明表示,每个文件的配置最大为1Mb,单次请求的文件的总数不能大于10Mb。要更改这个默认值需要在配置文件(如application.properties)中加入两个配置
需要设置以下两个参数
multipart.maxFileSize
multipart.maxRequestSize
Spring Boot 1.3.x或者之前
multipart.maxFileSize=100Mb multipart.maxRequestSize=1000Mb
Spring Boot 1.4.x或者之后
spring.http.multipart.maxFileSize=100Mb spring.http.multipart.maxRequestSize=1000Mb
或者
/**
* 文件上传配置
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//文件最大
factory.setMaxFileSize("10240KB"); //KB,MB
/// 设置总上传数据总大小
factory.setMaxRequestSize("102400KB");
return factory.createMultipartConfig();
}
该段代码加在启动类里面
bug3:ajax请求时,org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
解决办法:spring boot不支持application/x-www-form-urlencoded,需指定contentType: "application/json;charset=UTF-8",并加上data:JSON.stringify(data),转化为json格式
bug4:"application/json;charset=UTF-8",请求时报找不到对应body构造器
解决办法:对应的body需加上空的构造方法
bug5:注解错误could not autowire no beans,不能自动装配,可能是编译器未能正确识别该bean类
解决办法:在该bean类下添加注解:@Compent
bug6:重定向时中文乱码
解决办法:URLEncoder.encode(username,"UTF-8")
bug7:使用spring boot时找不到对应的html页面,即出现404
解决办法:添加依赖,compile('org.springframework.boot:spring-boot-starter-thymeleaf'),spring boot默认的是thymeleaf模板