我在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.
首先我虽然可能是会话对象没有保存值,所以我检索了String中的值并且其工作正常。但是我遇到了list的问题。下面是我的Jsp代码.`<% 尝试{ 购物车displayCart =(购物车)session.getAttribute(“getValue”);
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..!
<%
}
%>`
任何人都可以帮我把..
任何帮助将不胜感激..
谢谢
答案 0 :(得分:1)
您的堆栈跟踪清楚地说明了为什么会出现此问题。您可能使用Java 5,但Diamond运算符是Java 7功能。所以,有两个解决方案
请勿使用以下声明中的钻石操作符。
List<String> ProdRefCode = new ArrayList<String>();
答案 1 :(得分:1)
而不是像这样声明ArrayList
ArrayList<String>ProdRefCode=new ArrayList<>();
声明ArrayList Like
List<String> ProdRefCode= new ArrayList();
即不要使用&lt;&gt;在右侧