【问题标题】:Exception while creating List on jsp在jsp上创建列表时出现异常
【发布时间】:2015-04-04 16:52:21
【问题描述】:

在 jsp 上创建 List 时遇到问题。我不确定它是一个错误(虽然不太可能)还是我实现它的方式有问题。 当我尝试在我的列表对象中存储值时,我得到了这个异常

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6199: Generated servlet error:
source value 1.5 is obsolete and will be removed in a future release

PWC6199: Generated servlet error:
target value 1.5 is obsolete and will be removed in a future release

PWC6199: Generated servlet error:
To suppress warnings about obsolete options, use -Xlint:-options.

PWC6197: An error occurred at line: 18 in the jsp file: /OrderCheckOut.jsp
PWC6199: Generated servlet error:
diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1 logs.

首先我虽然可能是会话对象没有保存该值,所以我检索了字符串中的值并且它工作正常。但是我遇到了列表问题。下面是我的 Jsp 代码。`

         String firstname=displayCart.getProdRefCode().toString();
          //This is causing problem I suppose
         ArrayList<String>ProdRefCode=new ArrayList<>();
         ProdRefCode.add(firstname);
        } catch (Exception ex) {
    %><p> There is some problem..check..!
        <%
            }
        %>`

谁能帮我把..

任何帮助将不胜感激..

谢谢

【问题讨论】:

  • @Masud 这不会修复 1.5 下菱形运算符的使用。
  • @DaveNewton,是的,你是对的。
  • 我还想补充一点,我使用的是 Netbeans 8.0.2,servlet 版本是 3.1.. 如果有帮助的话

标签: java jsp servlets


【解决方案1】:

您的堆栈跟踪清楚地说明了为什么会发生此问题。您可能使用 Java 5,但菱形运算符是 Java 7 的特性。所以,有两种解决方案

  1. Java 7 更新
  2. 不要使用如下声明的菱形运算符。

    List<String> ProdRefCode = new ArrayList<String>();
    

【讨论】:

    【解决方案2】:

    而不是像这样声明 ArrayList

    ArrayList<String>ProdRefCode=new ArrayList<>();
    

    声明 ArrayList Like

    List<String> ProdRefCode= new ArrayList(); 
    

    即不要使用右侧的

    【讨论】:

    • 这不是和五个小时前一样的答案吗?
    • Masud 给的那个在右侧有 并且他写了“不要使用菱形运算符”。所以我不确定他的建议是什么..@Dave 和 @Masud 感谢您的帮助:)
    猜你喜欢
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-07
    • 2015-02-17
    相关资源
    最近更新 更多