---
title: "The method getDispatcherType() is undefined for the type HttpServletRequest"
author: "wujierd"
date: "2014-12-17T23:56:39Z"
tags: []
categories: ["编程语言"]
slug: "the-method-getdispatchertype-is-undefined-for-the-type-httpservletrequest"
draft: false
lastmod: "2014-12-17T23:57:47Z"
id: 2167210
url: "https://wujierd.iteye.com/blog/2167210"
---

今天遇到一个很奇葩的问题
在启动tomcat的时候出现如下问题。
The method getDispatcherType() is undefined for the type HttpServletRequest。
就是在HttpServletRequest没有定义getDispatcherType方法，我看了在HttpServletRequest里面确实没有getDispatcherType方法。servlet 3.0.1 和servlet 3.1.0都没有

![](http://dl2.iteye.com/upload/attachment/0104/4577/bd61ba58-cfb0-3640-9b52-2c2190b756df.jpg)

在ServletRequestWrapper里面才有


![](http://dl2.iteye.com/upload/attachment/0104/4581/7aae5feb-5c99-3b89-afba-410ff03e0292.jpg)

但是出问题的login_jsp.java是这样的

```java

  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

final java.lang.String _jspx_method = request.getMethod();
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method) && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET POST or HEAD");
return;
}

```

我只能把如下的代码删掉

```java

&& !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())

```


如果您有好的解决办法，麻烦贴出来。