首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp的<% %>中使用 像ArrayList<String> al = .的时候会报'<'是非法字符?该如何解决

2013-09-11 
jsp的% %中使用 像ArrayListString al ...的时候会报是非法字符??jsp的 %% 中使用像ArrayList

jsp的<% %>中使用 像ArrayList<String> al = ...的时候会报'<'是非法字符??
jsp的 <%   %> 中使用   像ArrayList <String>   al   =   ...的时候会报 ' < '是非法字符??

比如 <%@   page   language= "java "   import= "java.util.* "   pageEncoding= "UTF-8 "%>
<%
String   path   =   request.getContextPath();
String   basePath   =   request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
    <head>
        <base   href= " <%=basePath%> ">
       
        <title> My   JSP   'MyJsp.jsp '   starting   page </title>
       
<meta   http-equiv= "pragma "   content= "no-cache ">
<meta   http-equiv= "cache-control "   content= "no-cache ">
<meta   http-equiv= "expires "   content= "0 ">        
<meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
<meta   http-equiv= "description "   content= "This   is   my   page ">
<!--
<link   rel= "stylesheet "   type= "text/css "   href= "styles.css ">
-->

    </head>
   
    <body>
    <%  
    ArrayList <String>   al   =   new   ArrayList <String> ();
   
      %>
        This   is   my   JSP   page.   <br>
    </body>
</html>


报错   :
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:   26   in   the   jsp   file:   /testuig/MyJsp.jsp
Generated   servlet   error:
Syntax   error   on   token   " < ",   invalid   AssignmentOperator

An   error   occurred   at   line:   26   in   the   jsp   file:   /testuig/MyJsp.jsp
Generated   servlet   error:
Syntax   error   on   token   "= ",   !=   expected

An   error   occurred   at   line:   26   in   the   jsp   file:   /testuig/MyJsp.jsp
Generated   servlet   error:
Syntax   error   on   token   " < ",   (   expected

An   error   occurred   at   line:   26   in   the   jsp   file:   /testuig/MyJsp.jsp
Generated   servlet   error:
Syntax   error   on   token   "( ",   invalid   Expression


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)

[解决办法]
http://www.javaworld.com.tw/jute/post/print?bid=6&id=104574
參考一下
^_^
[解决办法]
泛型是1.5以后的东西.
[解决办法]
针对这个问题我刚才试了一下,
<%
ArrayList <String> al = new ArrayList <String> ();

%>
在jsp中这样写没有问题~~~

你看下的你那个项目的jdk是不是1.5以上的,因为泛型只在1.5以后才有

或许你再看看代码的其它地方,可能是其它地方的错~
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行