springMVC错误集锦
来源:互联网 发布:mac 系统升级最新版本 编辑:程序博客网 时间:2024/04/27 17:13
spring项目启动相关错误集锦:
问题一
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
解决办法:
- Open the project’s properties (e.g., right-click on the project’s
name in the project explorer and select “Properties”). - Select “Deployment Assembly”.
- Click the “Add…” button on the right margin.
- Select “Java Build Path Entries” from the menu of Directive Type and
click “Next”. - Select “Maven Dependencies” from the Java Build Path Entries menu
and click “Finish”.
You should see “Maven Dependencies” added to the Web Deployment Assembly definition.
问题二
java.lang.NoSuchMethodError: org.springframework.web.servlet.HttpServletBean
解决办法:
是因为把jar包加错了,导致版本对应不上,原来加的jar包为
<dependency> <groupId>spring</groupId> <artifactId>spring-webmvc</artifactId> <version>1.0.2</version></dependency>
改为对应版本的就好了
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.3.9.RELEASE</version></dependency>
问题三
Spring mvc 报错java.lang.ClassNotFoundException: org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
解决办法:
这个问题一般出现在使用Spring 4时,因为:
spring3.x是org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
spring4.x是org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
所以Spring3.x配置如下:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jsonHttpMessageConverter" /> </list> </property> </bean> <bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>application/json;charset=UTF-8</value> </list> </property> </bean>
Spring 4.x配置如下:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jsonHttpMessageConverter" /> </list> </property> </bean> <bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>application/json;charset=UTF-8</value> </list> </property> </bean>
问题四
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mappingJacksonHttpMessageConverter’
解决办法:
添加
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.9.0.pr4</version></dependency><dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.0.pr4</version></dependency>
问题五
有时候访问url时候发现访问不了,有可能是@RequestMapping写错了,或者xml文件配错了,还有一种SB的可能是访问路径的规则<url-pattern>*.do</url-pattern>
定的有后缀,但是访问时候忘了加后缀,如*.do等,所以url为http://127.0.0.1:8080/mdl/user/3/showUser.do
;
问题六
springMVC 中访问controller时,jsp页面的值总是显示${user.name}并不现实值
解决办法:
原来是<%@ page isELIgnored="false" %>
没有加如果一定要追查为什么,只能说,默认EL的忽略是true的,所以EL是没法使用的。
以上是通过EL表达式取值,如果不通过EL表达式,直接从request中取值,则不用加<%@ page isELIgnored="false" %>
- springMVC错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 错误集锦
- 你不知道javascript
- 解决web项目请求乱码问题
- Linux统计/监控工具SAR详细介绍
- 【hadoop】三种模式的区别
- 如何在js文件中动态加载另一个js文件?
- springMVC错误集锦
- Java面试考察范围
- JAVA开发中遇到的异常总结
- python中执行shell
- 【数据结构】DFS深度优先搜索(分别使用邻接矩阵、邻接表)
- Fetch封装
- Git学习总结(三):分支与标签管理
- HTML-meat标签
- 【面试题】剑指offer17--合并两个递增的链表,结果还是递增