SpringMVC-HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
来源:互联网 发布:程序员 博客 编辑:程序博客网 时间:2024/05/29 12:49
在进行SpringMVC开发时,遇到了如下错误:
Springmvc配置文件如下所示:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd "><!-- 1 处理器适配器 所有处理器适配器都实现 HandlerAdapter接口 --><beanclass="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /><!-- http请求处理器适配器,实现HttpRequestHandler接口 --><bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"/><!-- 2 配置加载Handler(实现controller接口) --><bean id="itemsController1" name="/queryItems_text.action" class="com.sw.ssm.controller.ItemsController1"/><!-- 配置handler(实现HttpRequestHandler接口) --><bean id="itemsController2" class="com.sw.ssm.controller.ItemsController2"/><!-- 配置加载注解的Handler(url已通过注解的方式配置在url中) --><!-- 单个配置(在实际开发中不常用) --><bean class="com.sw.ssm.controller.ItemsController3"/><!-- 通过组件扫描的方式加载 --><!-- <context:component-scan base-package="com.sw.ssm.controller"></context:component-scan> --><!-- 3 处理器映射器 --><!-- 根据bean的name进行查找Handler 将action的url配置在bean的name中 --><beanclass="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /><!-- 简单url映射 --><bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><property name="mappings"><props><!-- 对itemsController1进行url映射,url为:/queryItems1.action --><prop key="/queryItems1.action">itemsController1</prop><prop key="/queryItems2.action">itemsController1</prop><!-- 实现HttpRequestHandler的url映射 --><prop key="/queryItems3.action">itemsController2</prop></props></property></bean><!--注解适配器 --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/><!--注解映射器(与非注解可并存) --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/><!-- mvc注解驱动(可代替注解适配器与注解映射器的配置),默认加载很多参数绑定方法(实际开发时使用) --><!-- <mvc:annotation-driven></mvc:annotation-driven> --><!-- 4 视图解析器 --><!-- 解析jsp视图,默认使用jstl --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean></beans>
网上的说法众说纷纭,有说改变jdk版本的,也有说改变spring版本的。
但经过测试,这并不能解决问题。
原因在于:
<!-- 通过组件扫描的方式加载 --><context:component-scan base-package="com.sw.ssm.controller"></context:component-scan>
这里只用了扫描包的方式进行加载,但是在上面:
<!-- 2 配置加载Handler(实现controller接口) --><bean id="itemsController1" name="/queryItems_text.action" class="com.sw.ssm.controller.ItemsController1"/><!-- 配置handler(实现HttpRequestHandler接口) --><bean id="itemsController2" class="com.sw.ssm.controller.ItemsController2"/>
1、更换包名
即将使用配置文件与注解两种方式的handler文件放在两个包下
2、注解使用单个加载的方式,如下:
<!-- 单个配置(在实际开发中不常用) --><bean class="com.sw.ssm.controller.ItemsController3"/>
则配置文件如下:
<!-- 1 处理器适配器 所有处理器适配器都实现 HandlerAdapter接口 --><beanclass="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /><!-- http请求处理器适配器,实现HttpRequestHandler接口 --><bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"/><!-- 2 配置加载Handler(实现controller接口) --><bean id="itemsController1" name="/queryItems_text.action" class="com.sw.ssm.controller.ItemsController1"/><!-- 配置handler(实现HttpRequestHandler接口) --><bean id="itemsController2" class="com.sw.ssm.controller.ItemsController2"/><!-- 配置加载注解的Handler(url已通过注解的方式配置在url中) --><!-- 单个配置(在实际开发中不常用) --><bean class="com.sw.ssm.controller.ItemsController3"/><!-- 通过组件扫描的方式加载 --><!-- <context:component-scan base-package="com.sw.ssm.controller"></context:component-scan> --><!-- 3 处理器映射器 --><!-- 根据bean的name进行查找Handler 将action的url配置在bean的name中 --><beanclass="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /><!-- 简单url映射 --><bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><property name="mappings"><props><!-- 对itemsController1进行url映射,url为:/queryItems1.action --><prop key="/queryItems1.action">itemsController1</prop><prop key="/queryItems2.action">itemsController1</prop><!-- 实现HttpRequestHandler的url映射 --><prop key="/queryItems3.action">itemsController2</prop></props></property></bean><!--注解适配器 --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/><!--注解映射器(与非注解可并存) --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/><!-- mvc注解驱动(可代替注解适配器与注解映射器的配置),默认加载很多参数绑定方法(实际开发时使用) --><!-- <mvc:annotation-driven></mvc:annotation-driven> --><!-- 4 视图解析器 --><!-- 解析jsp视图,默认使用jstl --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean></beans>
0 0
- HTTP Status 500 - Servlet.init() for servlet springMVC threw exception
- HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- SpringMVC-HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- 出现 HTTP Status 500 - Servlet.init() for servlet springmvc threw exception 异常的原因及解决方法
- springMVC 配置出现Status 500 - Servlet.init() for servlet springMVC threw exception
- HTTP Status 500 - Servlet.init() for servlet SpringMVC threw exception, 元素 'beans' 必须不含字符 [子级], 因为该类
- HTTP Status 500 - Servlet.init() for servlet CXFServlet threw exception
- javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception
- javax.servlet.ServletException: Servlet.init() for servlet springMVC threw exception
- javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception
- Java Web Servlet.init() for servlet springMVC threw exception解决
- Spring MVC - HTTP Status 500 - Servlet.init() for servlet loginDispacher threw exception
- 关于SpringMVC设置注解注入出现Servlet.init() for servlet springMVC threw exception 错误解决方式
- 报javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception异常
- 报javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception异常 的解决方案
- 『sklearn学习』利用 Python 练习数据挖掘
- 用代码实现你来这个世界多少天了.
- jquery的入口函数
- public、private、default、protected总结
- 入门训练 Fibonacci数列
- SpringMVC-HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
- setIconifiedByDefault() setIconified() onActionViewExpanded()对比
- 简单的MapReduce程序wordCount
- UIFramework之功能分析
- 初学者parseInt()和parseFloat()的理解(仅供参考,老司机笔下留情)
- 使用wxWidgets进行跨平台的C++开发
- g_2 + g_3
- cocos2d-x游戏摇杆开发
- 微痕迹简介