the method getDispatcherType() is undefined for the type HttpServletRequest

环境介绍:

        jdk1.7

       tomcat 8.0

       eclipse 4.4.1

       maven 3.2.3

部署一个简单应用工程,访问页面后发现,报如下错误:

   

错误原因分析:

web.xml内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
                        version="3.0">
  <display-name>platform</display-name>
  <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
   </welcome-file-list>
</web-app>

访问index.jsp报错,但访问index.html是正常的。

在部署后的工程中查找发现如下jar包:

servlet-api-2.3.jar

初步判定是该包与tomcat的容器jar包冲突引起的。尝试直接在部署工程中删除。

结果:

   index.jsp页面访问正常。

问题:

       该包是如何部署在工程中的?

问题分析:

       分析pom.xml文件中的每一个包,发现是spring-hibernate3会传递依赖servlet-api-2.3.jar包;

解决方法:

    加入以下红色部分:

       <dependency>  
        <groupId>org.springframework</groupId>  
        <artifactId>spring-hibernate3</artifactId>  
        <version>2.0.8</version>  
        <type>jar</type>  
        <exclusions>  
           <exclusion>      
                <groupId>javax.servlet</groupId>    
                <artifactId>servlet-api</artifactId>  
           </exclusion>  
        </exclusions> 

    </dependency>  

验证:

    重新部署运行后,一切访问正常。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值