1. 程式人生 > >The method getDispatcherType() is undefined for the type HttpServletRequest錯誤解決方法

The method getDispatcherType() is undefined for the type HttpServletRequest錯誤解決方法

使用Eclipse Luna版本,jdk1.7和tomcat8.0開發JAVA EE應用。寫一個簡單的JSP部署後訪問報JSP編譯錯誤,具體錯誤資訊如下:

The method getDispatcherType() is undefined for the type HttpServletRequest

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
    org.apache.jasper.compiler.ErrorDispatcher
.javacError(ErrorDispatcher.java:198) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450) org.apache.jasper.compiler.Compiler.compile(Compiler.java:361) org.apache.jasper.compiler.Compiler.compile(Compiler.java:336) org.apache.jasper.compiler.Compiler.compile(Compiler.java
:323) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:570) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java
:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

在網上搜了下沒找到解決辦法,自己分析了一下,其實錯誤很明顯解決方法也很簡單。

大家都知道JSP頁面會被WEB容器翻譯成Servlet,最終會編譯成class檔案,這個錯誤的意思是:”HttpServletRequest中找不到getDispatcherType()方法的定義”。

原因是本人在classpath中添加了j2ee.jar包,這個jar包是從老專案中拷貝出來的,屬於早期的j2ee規範,HttpServletRequest缺少getDispatcherType()的定義。

解決方案:

1.將j2ee.jar從編譯路徑中移除。

2.在專案上點選右鍵->Properties->Java Build Path->Libraries,點選Add Library->Server Runtime,點選Next按鈕,點選 Apache Tomcat v8.0, 點選Finish按鈕即可。
這裡寫圖片描述

這裡寫圖片描述

這裡寫圖片描述

如果你的專案中報這個錯誤,可能就是這個原因。

相關推薦

The method getDispatcherType() is undefined for the type HttpServletRequest錯誤解決方法

使用Eclipse Luna版本,jdk1.7和tomcat8.0開發JAVA EE應用。寫一個簡單的JSP部署後訪問報JSP編譯錯誤,具體錯誤資訊如下: The method getDispatcherType() is undefined for the

The method getDispatcherType() is undefined for the type HttpServletRequest 升級到tomcat8

配置專案,從tomcat低版本,放到tomcat8時,正常的專案居然報錯了: The method getDispatcherType() is undefined for the type HttpServletRequest 從網上查資料,找可能出現這個問題的因素:

The method getTextContent() is undefined for the type Node 錯誤解決

eclipse 中 如果加入了 其他了xfire 等其他xml解析包的話,使用org.w3c.dom.Node下的getTextContent()方法會出現The method getTextContent() is undefined for the type Node 提示,解決方法如下:

The method getInstance() is undefined for the type Service

總結一下關於類似這種問題: 1、導錯包了,本來匯入第二個包,你卻匯入了第一個包。 這種錯誤的話,編輯器會提示你,MapUtils cannot be resolved 解決方案:修改包即可。 2、在專案中匯入了這個jar包,但該版本jar包不支援這個方法或者是

MyEclipse 下 the method getTextContent() is undefined for the type Element

在myeclipse下 pagefield = dc.createElement("Field"); pagefield.setAttribute("Name",

The method getTextContent() is undefined for the type Node錯誤

重灌系統後開啟以前做的工程出現了這個錯誤 收集了一下錯誤原因 CSDN: 因為你呼叫的那個方法是jdk下的那個包裡的類,而在web專案裡卻呼叫了J2EE裡的xml-apis.jar下的org.w3c.dom。(實際上要呼叫的那個方法是在jdk下的rt.jar下的org.

The method iterator() is ambiguous for the type KafkaStream

slf4j 後來 pac upd 資料 keep bubuko 分享圖片 sse 最近在學習消息總線Kafka的時候,在IDEA中寫了一個簡單的生產者和消費者demo。但是消費者端一直報錯。錯誤信息如下: 1 ConsumerIterator<by

The attribute required is undefined for the annotation type XmlElementRef

生成 bool target sta div val 方式 java 需要 異常描述: 幾天沒用的項目導進Eclipse中發現有異常 public class BooleanFeatureType extends FeatureBaseType{ @Xm

java 呼叫方法引起歧義:The method XXX is ambiguous for the type XX

The method XXX is ambiguous for the type XX eclipse編譯報錯。 分析原因:方法歧義,是編譯器無法確定,程式碼中使用哪一個方法。 1、呼叫的是自己編寫的方法 public class Ambiguous {     publi

專案程式碼報:The method xx方法( ) is undefined for the type XX類

一般報這個錯,三種情況: (1)導錯包了,比如 本來匯入第二個包,你卻匯入了第一個包。 這種錯誤好發現,因為編輯器會提示你,MapUtils cannot be resolved ,修改

踩了兩次坑The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory的解決方法

後來在網上查了查,說是因為專案中有像jsp-api.jar servlet-api.jar跟tomcat6的lib中同樣的包,但版本比tomcat6的版本要低,在執行的時候,因為會優先載入專案中的包,所以 產生了錯誤,把專案中和tomcat相同的包刪除(必須刪除,如果替換

gatling壓力測試工具啟動gatling.bat命令行窗口報Error occurred during initialization of VM Could not reserve enough space for 1048576KB object heap錯誤解決方法

大於 spa ava color default class -xms 查看系統 測試 原因是:Java虛擬機(JVM)分配的內存大於系統可用內存數,所以沒有足夠的空間分配給JVM來創建Object 解決方法:編輯gatling.bat文件,查看系統剩余內存大小,修改分配的

the user operation is waiting for "Building workspace" to complete

問題說明:   the user operation is waiting for "Building workspace" to complete    (該使用者操作正在等待 "Building Workspace" (編譯當前工作區) 操作完成。)    當 Eclipse 檢

the virtual machine is configured for 64-bit guest operating

                解決辦法:修改BIOS設定 Security--Virtualization--Inter(R) Virtualization Technolog 設定為enable本機安裝的是WIN 7 ,詳細版本是:Windows 7 Ultimate, 32-bit 6.1.7601,

Eclipse the user operation is waiting for "buiding workspace" to complete

在Build Android 工程的時候會遇到:the user operation is waiting for "buiding workspace" to complete問題,導致Eclips

My Fellow Engineers, It Is Time For the Greatest Invention of All

My Fellow Engineers, It Is Time For the Greatest Invention of Allthisiscolossal.comEngineering Reality 101Every day, scores of engineers pick up where they

The Race is on for the top Crypto DEX

The Race is on for the top Crypto DEXDevelopers pushing multiple decentralized exchanges.In my studies last week I discovered a rush of companies who are s

php composer.phar install error The openssl extension is required for SSL/TLS protection

php composer.phar install  error $ php composer.phar install   [Composer\Exception\NoSslException]  

解決composer提示The openssl extension is required for SSL/TLS protection...

錯誤提示 The openssl extension is required for SSL/TLS protection but is not availab le. If you

Composer The openssl extension is required for SSL/TLS protection

=============================新的解決方法(較完善)=================================     Composer 是 PHP5以上 的一個依賴管理工具。它允許你申明專案所依賴的程式碼庫,它會在你的專案中為