Arraylist不在JSP scriptlet中工作

时间:2014-08-15 18:41:58

标签: java jsp scriptlet

当我尝试使用Jboss 4.0的Java 1.6 / 1.7中的代码时,我遇到了异常。我这里没有选择使用jstl。

Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 13 in the jsp file: /sample.jsp
Generated servlet error:
Syntax error on token "<", invalid AssignmentOperator

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

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

An error occurred at line: 13 in the jsp file: /sample.jsp
Generated servlet error:
Syntax error on token "(", invalid Expression           
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)

我的Jsp文件如下:

    <%@ page import="java.util.*" %>  

    <% ArrayList<String> list=new ArrayList<String>();  
       list.add("Hello");  
    %>  

    <%= list.get(0) %>

2 个答案:

答案 0 :(得分:0)

List <String> list = ArrayList<String>(); 尝试使用List not ArrayList

答案 1 :(得分:0)

提供完全限定的类名称:

java.util.ArrayList<String> Orig_office_type = new java.util.ArrayList<String>();

这将解决问题。