getDispatcherType() is undefined for the type HttpServletRequest

使用maven创建web工程,服务器选择了Tomcat 8,而servlet的版本采用的是2.5.

<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
		</dependency>

 

启动Tomcat 8,转发到jsp时出现异常信息:

getDispatcherType() is undefined for the type HttpServletRequest

这个是由于Tomcat 8支持的servlet版本与maven指定的servelet版本有冲突导致的。

 

可以采用如下的方法解决该error

 

<dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>servlet-api</artifactId>
	<version>2.5</version>
</dependency>

 

改成

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
 </dependency>

即可。

猜你喜欢

转载自mouselearnjava.iteye.com/blog/2310885