2014-11-08 60 views
1

當我想運行演示時,網頁顯示以下錯誤,爲什麼?
它是版本問題嗎?我正在運行Apache Tomcat/8.0.14,springframework 4.1.1。如何在Intellij中使用Tomcat 8?

HTTP Status 500 - Unable to compile class for JSP: 
Unable to compile class for JSP: 

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [42] in the generated java file: 

[/home/cuifugang/.IntelliJIdea13/system/tomcat/Tomcat_8_0_14_springMVCFirst/work/Catalina/localhost/ROOT/org/apache/jsp/WEB_002dINF/pages/hello_jsp.java] 
The method getDispatcherType() is undefined for the type HttpServletRequest 

Stacktrace: 
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) 
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199) 
    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:564) 
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) 
    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) 
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172) 
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) 
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228) 
    org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011) 
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955) 
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) 
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:618) 
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.14 logs. 
+0

我在Tomcat 8.0,Spring 4.1.1和IntelliJ中看到過類似的問題。嘗試刪除IntelliJ項目文件並重新導入項目(例如,從您的Maven'pom.xml'文件)。 (這解決了我的問題)。 – Jesper 2014-11-08 09:07:36

+0

查看事件日誌,您可能錯過了一條邀請您下載所需庫的消息。 – 2014-11-08 10:25:44

回答

0

我有同樣的問題。它在pom.xml中將servlet-api的作用域設置爲「提供」之後起作用

<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
    <scope>provided</scope> 
</dependency> 
+0

yeah,thank you @ Qingzi – 2015-07-28 09:56:51