发表于: 2019-12-28 20:32:30
1 1164
整理报错
1在web.xml中<listener-class>标签报红
参考(https://q.cnblogs.com/q/74982/)
解决:改用2.5的版本
答案节选:
Servlet3.0是J2EE6.0规范的一部分,跟随J2EE6.0一起发布,并且Tomcat7.0已经完全支持Servlet3.0 ; 平时,我们一般使用tomcat6.0,是不能够使用servelt3.0的,tomcat6.0还不能支持那些规范; 至于说,为毛线不能使用lintener-class,是因为在web-app_3_0.xsd结构定义文件中,根本就不提倡这些配置,因为Servlet3.0已经支持注解形式;
当时解决了报红的问题。但后来我其他部分调试好了后,改回3.0也没报错。
2BeanCreationException
是少依赖的问题,输入mvn dependency:tree打依赖树:
少了spring-aspects,spring-core等依赖,加上
3mybatis绑定错误
错误:org.apache.ibatis.binding.BindingException: Invalid bound statement
使用了下面的方法检查,都没有解决。排除了包名不同等低级错误。
https://blog.csdn.net/softwarehe/article/details/8889206
又找到了oschina一个人的帖子,有个回答感觉靠谱
https://www.oschina.net/question/113302_228910
是的,是没有在pom.xml配置build包含 xml,导致target目录下没有userMapper.xml -by 唐小明生
方案一:自定义一个插件,绑定某个生命周期,比如compile,然后插件目标的功能是将源码包下的xml文件copy到相应的输出目录。(现有插件是否有已有这个功能,通过简单的配置就能完成?我还不清楚)
方案二:在maven工程的src/main/resource目录下建和mapper接口类相应的包,将每个mapper.xml存在这里
这里我插件玩的不熟,所以没办法,只能手动在resources目录下建包,把每个mapper.xml手动粘贴进去
4请求参数乱码问题
在web.xml添加post乱码filter
对于get请求中文参数出现乱码解决方法有两个:
修改tomcat配置文件添加编码与工程编码一致,如下:
另外一种方法对参数进行重新编码:
String userName = new String(request.getParamter("userName").getBytes("ISO8859-1"),"utf-8")
ISO8859-1是tomcat默认编码,需要将tomcat编码后的内容按utf-8编码
5maven平台编码问题
参考
https://blog.csdn.net/jinguangliu/article/details/43373203
在pom.xml文件的设置编码即可
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
6json格式数据问题
1.请求是json格式
debug窗里报下面的错误:
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
浏览器报下面的错误:
HTTP Status 415 -
anddescription The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
2.请求是key/value格式
debug窗里报下面的错误:
java.lang.IllegalArgumentException: No converter found for return value of type: class com.iot.learnssm.firstssm.po.ItemsCustom
参考
多加一个依赖jackson-databind(之前只加了jackson-mapper-asl的依赖, 间接依赖jackson-core-asl,但还不够
还有一个重新写的task2 ssm bug:Failed to load ApplicationContext
留着折磨师兄
明日任务:继续完成剩下的任务
今日问题:遗留问题1 spring依赖太多没搞清楚 需要仔细捋一下 2ssm的Failed to load ApplicationContextBUG没解决
评论