1.在Spring MVC中,前台提交 form,tomcat 返回 http status 400 The request sent by the client was syntactically incorrect,控制台无任何错误输出。
问题原因:经过查阅资料发现,这是因为前台 form 表单中的某些参数和后台接受的参数类型不一致导致的。即参数名称相同,但是类型不一致。
解决办法:检查 form 表单中的参数和后台的参数对应,看是否有参数名相同但是类型不一致的情况。然后在日志中即可看到 spring 抛出的异常信息,即可发现哪个参数出现了错误。
2.在基于接口实现的mybatis简单实例中,出现如下错误提示:
Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.yihaomen.mybatis.inter.IUserOperation is not known to the MapperRegistry.
问题原因:经查阅资料,发现是user.xml中关于Map的地址写错了
<mapper namespace="com.yihaomen.mybatis.models.UserMapper">
解决办法:如上的UserMapper为错误的,原因在于基于接口的实现中,此处映射的地址应为接口的地址,也就是
<mapper namespace="com.yihaomen.mybatis.inter.IUserOperation">
3.在sql的url配置中,提示如下错误:
The server time zone value '?й???????' is unrecognized or represents more than one time zone
解决办法:经查阅,如上问题是时区错误,添加代码serverTimezone=GMT
即可。
4.在配置文件中遇到如下错误提示:
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.xxx.yyy.mappers.StudentMapper.getById
问题原因:经仔细检查与对比,发现mapper.xml文件不是直接放在classess目录下的,所以最初的写的配置
<property name="mapperLocations" value="classpath:*Mapper.xml" />
是找不到mapper配置文件的
解决办法:需要增加 **/来解决此问题
<property name="mapperLocations" value="classpath:**/*Mapper.xml" />