日期:2014-05-16  浏览次数:20420 次

JSP中不能使用范型?

早上起了个大早来解决服务器上JSP报错的问题。

页面提示如下:

?

HTTP Status 500 -

type Exception report

message

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: 16 in the jsp file: /content/media_category.jsp
Generated servlet error:
Syntax error on token "<", invalid AssignmentOperator

An error occurred at line: 16 in the jsp file: /content/media_category.jsp
Generated servlet error:
Syntax error on token "=", != expected


	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)
	com.huilin.commons.filter.PrivilegeCheckFilter.doFilter(PrivilegeCheckFilter.java:123)
	com.huilin.commons.filter.CleanupDatabaseConnectioniFilter.doFilter(CleanupDatabaseConnectioniFilter.java:44)
	com.huilin.commons.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

Apache Tomcat/5.5.9

?而第16行为 “<%” 和回车。即java代码的开头。就这么一个错误可算是折腾死我了。因为本地没有任何问题,只好google一下。找到 这篇文章?才恍然大悟,原来是范型出的问题。可是本地和服务器的jdk都是1.5.0_03,tomcat本地为5.5.26,服务器为5.5.9。不是版本问题。那就是配置了。这篇文章 中给出了配置问题,原来是JSP的问题。只好把范型都删掉了。

还出了个问题是: Long 型转换问题, setxxx(Long value) 这个方法,我在JSP中用 setxxx(Long.parseLong("123")) ,也是本地可以,服务器上不行。只好改成 new Long("123") 了。

?

1 楼 spyker 2009-09-02  
jsp中为什么有java代码?
2 楼 jncz 2009-09-02  
spyker 写道
jsp中为什么有java代码?

jsp为什么不能有java代码?
3 楼 spyker 2009-09-02  
jncz 写道
spyker 写道
jsp中为什么有java代码?

jsp为什么不能有java代码?

不到万不得已不要有
不然 也许你会哭
4 楼 jncz 2009-09-02  
spyker 写道
jncz 写道
spyker 写道
jsp中为什么有java代码?

jsp为什么不能有java代码?

不到万不得已不要有
不然 也许你会哭

这与楼主的问题有关系吗?jsp本身是允许有java代码的,楼主的问题是为什么这些java代码,在使用了泛型之后出错. 这与是否应该在jsp中写java代码有关系吗?
5 楼 spyker 2009-09-02  
我觉的好的web设计之类 或者良好的代码控制 不应该在jsp出现java代码
和jsp允许不允许没关系

你完全可以在jsp中把你能加的全加进去
如果你愿意

我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.aiyiweb.com/j2ee/2308.html