今天写一个极简单的功能,偷懒了,直接在JSP中嵌代码,为了省去Box/Unbox的麻烦,用了泛型.一跑起来,问题就来了,访问页面显示:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
Syntax error on tokens, delete these tokens
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
Syntax error on token "<", ( expected
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
Syntax error on token "(", invalid Expression
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
An error occurred at line: 4 in the jsp file: /knowledge/index.jsp
Generated servlet error:
subContents cannot be resolved or is not a field
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
查来查去,没找出问题来,网上简单搜一下,也没发现相关解决方法,看到出错信息中出现尖括号,会不会是由于泛型造成错误呢,于是把泛型去掉,按传统方式处理.再运行一下,错误消失了.看来猜测的没错,但为什么泛型会造成这个问题,以及还有哪些版本的Tomcat会出现这个问题,还没深究.