type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 5 in the jsp file: /index.jsp
ArrayList cannot be resolved to a type
2: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
3: <%@ page import="java.util.List"%>
4: <%
5: List<String> list = new ArrayList<String>();
6: list.add("test1");
7: list.add("test2");
8: list.add("test3");
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:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:363)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:338)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:325)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:580)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
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:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.51 logs.
今天寫了個頁面本來是靜態頁面,但是客戶想讓改造成動態的,想到改成jsp。於是想先用小腳本寫一個list在頁面試試看看,但是出現了這個異常,網上很多說法,比如tomcat和jre版本不兼容,建議換成高版本的tomcat,這個我檢查過不存在這個問題,最後在網上看到有人說 定義的時候最好不要加泛型,
於是把泛型去掉果然好了。記錄一下,jsp引用小腳本,關於定義List的時候,不要加泛型!