1.问题描述:
前端页面携带参数发起ajax的GET请求,controller层用@ModelAttribute+对象接收,无法接收前端请求和参数;
2.异常信息:
2021-03-10 14:49:03.467 [http-nio-8082-exec-1] DEBUG [springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping] - Looking up handler method for path /xxx
2021-03-10 14:49:03.467 [http-nio-8082-exec-1] DEBUG [springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping] - looking up handler for path: /xxx
2021-03-10 14:49:03.475 [http-nio-8082-exec-1] DEBUG [springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping] - Did not find handler method for [/xxx]
3.请求URL:
http://localhost:9091/xxx?opCode=&processPid=&processStartUser=&processType=&processStartTime=¤tPage=1&hostId=&_=1615357331828
4.实体类:
/**
* 进程启动时间
*/
@Column(name = "process_start_time")
private Date processStartTime;
5.原因:
因为ajax的GET请求携带参数在url中,参数类型为字符串型,而后端接收的实体类字段processStartTime为Date类型,springMVC在接收参数时,无法将字符创型转换为Date类型,所以请求参数和接收参数不一致导致无法接收前端发起的请求
6.解决方法:
/**
* 进程启动时间
*/
@Column(name = "process_start_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date processStartTime;
|