日期:2014-05-18  浏览次数:20663 次

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