1.常见报错
1.1idea中使用mybatis遇到Could not autowire. No beans of 'xxxx' type found
解决方案:安装mybatis插件
1.2Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
解决方案:1.mapper.xml文件得与相应的java文件在同一个目录下。
1.3java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer;
解决方案:mybatis-spring版本过低导致,添加版本更高的jar包
1.4编译文件中就没有编译mybatis的xml文件
解决方案:在pom.xml中添加如下代码
src/main/resources
**/*.properties
**/*.xml
**/*.tld
false
src/main/java
**/*.properties
**/*.xml
**/*.tld
false
1.5java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig
Spring4测试的时候需要servlet3.0的支持
javax.servlet
javax.servlet-api
4.0.0
provided
1.6 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 'LIMIT 5' at line 1
SQL语句在单元测试中可以通过,但是在Spring测试模块中不能通过,得把后面的;号去掉
SELECT * from tb1_emp;
改为:
SELECT * from tb1_emp
1.7web路径的问题
不以“/”开始的相对路径,以当前资源的路径为基准,经常出现问题
以“/”开始的相对路径,以服务器的路径为标准(http://localhost:3309),需要加上项目名称
如/SSM_CRUD/static/js/jquery-3.2.1.min.js
1.8由于外键而不能truncate
SET FOREIGN_KEY_CHECKS=0;
来禁用外键约束.
之后再用
SET FOREIGN_KEY_CHECKS=1;
来启动外键约束.
truncate TABLE address;
truncate TABLE car;
truncate TABLE goods;
truncate TABLE login;
truncate TABLE money;
truncate TABLE `order`;
truncate TABLE orderitem;
truncate TABLE shop;
truncate TABLE `user`;
1.9使用jquery的load方法加载页面的时候被加载页面js不能使用的问题
$.ajax({
url : 'userInformation.html',
cache : true,
async:false,
success : function(html) {
$(".body_center_right").html(html);
}
});
2.0 radio使用checked获取不到被选radio的值的问题
男
女
if($("#user_genger input:eq(0)").prop("checked")){
userGender = $("#user_genger input:eq(0)").val();
}
else
userGender = $("#user_genger input:eq(1)").val();
2.1直接使用base64加密后的图片,base64位的数据前得加上,“,”也必须有
data:image/jpg;base64,
2.2 mybatis传参String时报错的解决方法
There is no getter for property named '*' in 'class java.lang.String
2.3Required String parameter is not present
发现是前端传的参数名与后端代码定义的参数名不一致导致的
2.4关于window.location.href 传中文参数 乱码问题
将window.location.href = "goodsList.html?goodsName=" +goodsName + "&pn=1";
改成
window.location.href = "goodsList.html?goodsName=" + encodeURI(encodeURI(goodsName)) + "&pn=1";
2.5一个特别奇葩的bug,在使用mybatis中的pagehelper插件进行分页的时候发现有时候分页成功,有时候分页失败。
PageHelper.startPage(pn,10);
List moneyList = iMoneyService.selectByUserId(userId);
PageInfo pageInfo = new PageInfo(moneyList,5);
PageHelper.startPage 方法调用后,后面必须有一个Mapper的查询方法,必须被消费掉。 否则会由于ThreadLocal的原因,当该线程被其他方法调用时被分页