1.
后端:
Resolved exception caused by Handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
前端:
报415错误
原因,ajax中contentType误写为contextType
2.
后端:
2018-02-09 14:04:01.665 WARN 6628 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity com.zyc.controller.AccountController.login(com.zyc.model.Account)
2018-02-09 14:04:01.665 WARN 6628 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity com.zyc.controller.AccountController.login(com.zyc.model.Account)
前端:
报400错误
检查发现表单中的数据转换成json后,json值为undefined
原因,
var json=JSON.stringify($("#form1").serializeObject);改为
var json=JSON.stringify($("#form1").serializeObject());///?()
serializeObject后加上()。旧版的ij编译器在直接选择serializeObject时并没有自动加括号。
3.
后端:
2018-02-09 14:18:53.569 ERROR 7460 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [arg1, arg0, param1, param2]] with root cause
org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [arg1, arg0, param1, param2]
前端:
报500错误
原因,
dao层,也就是mapper层中
Account login(String username,String password);改为
Account login(@Param("username") String username,@Param("password")String password);
4.
后端:
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where password = '41234321'' at line 1
前端:
报500错误
原因,
dao层中@Select里应为
"where username = #{username,jdbcType=VARCHAR} and"+ " password = #{password,jdbcType=VARCHAR}"
或
"where username = #{username,jdbcType=VARCHAR} and", "password = #{password,jdbcType=VARCHAR}"
不能是
"where username = #{username,jdbcType=VARCHAR} and"+ " where password = #{password,jdbcType=VARCHAR}"
也不能是
"where username = #{username,jdbcType=VARCHAR} and"+ "password = #{password,jdbcType=VARCHAR}"
5
注册时宠物种类下拉菜单的数据出不来
后端不报错
前端409错误
发现是在service层将
example.createCriteria().andCatidIsNotNull();
错写成了
example.createCriteria().andCatidIsNull();
6
后端
WARN 7528 --- [io-8080-exec-10] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not deserialize value of type java.lang.Integer from String "data[index].catid": not a valid Integer value; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.lang.Integer from String "data[index].catid": not a valid Integer value
at [Source: java.io.PushbackInputStream@2e22a57c; line: 1, column: 153] (through reference chain: com.zyc.model.Account["profile"]->com.zyc.model.Profile["catid"])
前端报400错误
原因是reg.js中应该是
$("#category").append("+data[index].name+"")
而不是
$("#category").append("+data[index].name+"")
注意上述代码option标签中value中的值。下图中lang和catid断点值会让错误更清晰