问题一:json数据格式转换异常
java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException
解决办法:
https://www.cnblogs.com/xingxing0521/p/5306347.html
1. 在pom.xml中添加依赖:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.1.0</version>
</dependency>
2. 在spingMvc的配置文件中添加配置;
<!-- jsons数据自动转换 -->
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
问题二:在pom文件中添加了依赖,但是运行时却报找不到某个类的异常
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
解决办法:
https://www.cnblogs.com/aisam/articles/4686362.html
1.右键点击项目--选择Properties
选择Deployment Assembly,在右边点击Add按钮,在弹出的窗口中选择Java Build Path Entries
2.点击Next,选择Maven Dependencies
3.点击Finish,然后可以看到已经把Maven Dependencies添加到Web应用结构中了
问题三:shiro错误
Servlet.service() for servlet [springMVC] in context with path [/blog] threw exception [Request processing failed; nested exception is org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.] with root cause
org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.
查了半天,结果发现是自己忘记在web.xml文件中配置shiro的filter了
另外,如果使用struts2框架的话,shiro的filter要配置在struts2的filter之前,具体原因看链接:
http://blog.youkuaiyun.com/gsying1474/article/details/9266181
问题四:struts2配置文件中配置访问路径的通配符,访问时url地址完全正确,但使用struts2 2.3以前版本是可以的,2.5以后的版本会报错误
HTTP Status 404 – Not Found
Type Status Report
Message There is no Action mapped for namespace [/] and action name [student_queryAllStudent] associated with context path [/CardSYP].
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.23
错误原因:struts2 2.5为了增加安全性,不再默认使用通配符,而是在struts.xml配置文件中增加了<allowed-methods>xxx</allowed-methods>配置,需要显示的定义允许匹配的方法。如下:
问题五:jsp文件中引入js文件有的生效,有的不生效
问题原因:经过action的配置文件跳转过去的页面,路径与原文件的路径可能不一样,因此找不到js文件
解决方法:使用绝对路径 直接写/项目名称/文件所在路径,但是这样也会有风险,项目名称发生变化时又会出错,因此推荐一种动态获取项目绝对路径的方式,即jstl表达式中的url标签,使用如下:
参考链接:https://blog.youkuaiyun.com/u013456370/article/details/52487660
https://blog.youkuaiyun.com/wym19830218/article/details/5503533
关于路径问题上面两位博主总结的很全面