ssm实践错误收集

问题一: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.csdn.net/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.csdn.net/u013456370/article/details/52487660 

https://blog.csdn.net/wym19830218/article/details/5503533

关于路径问题上面两位博主总结的很全面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值