session.getAttribute() 用 " 引用在值内使用时必须转义

发布于 2024-12-20 15:56:30 字数 841 浏览 2 评论 0 原文

我将会话的属性设置为:

HttpSession session = request.getSession();
System.out.println(al);
session.setAttribute("arraylist",al);

al 是 Employee 对象的列表。我还可以看到 System.out 正在控制台中打印。 但是当我尝试从 jsp 获取列表时:

<%
List<Employee> employees = (List<Employee>)session.getAttribute( "arraylist" );

for(int i=0;i<employees.size();i++){
  Employee emp = employees.get(i);
  out.println(emp.getFirstName());
  out.println(emp.getLastName());
  out.println(emp.getAddress());
  out.println(emp.getContact());
  out.println(emp.getEmail());
}   
%>

我收到错误:

Attribute value  (ArrayList<Employee>)session.getAttribute("arraylist") is quoted with " which must be escaped when used within the value

我正在使用 Tomcat 6.0.33。任何信息都会非常有帮助。

谢谢。

I am setting a attribute to the session as:

HttpSession session = request.getSession();
System.out.println(al);
session.setAttribute("arraylist",al);

The al is the list of Employee object. Also I can see the System.out is printing in the console.
But when I am trying to get the list from jsp as:

<%
List<Employee> employees = (List<Employee>)session.getAttribute( "arraylist" );

for(int i=0;i<employees.size();i++){
  Employee emp = employees.get(i);
  out.println(emp.getFirstName());
  out.println(emp.getLastName());
  out.println(emp.getAddress());
  out.println(emp.getContact());
  out.println(emp.getEmail());
}   
%>

I am getting the error:

Attribute value  (ArrayList<Employee>)session.getAttribute("arraylist") is quoted with " which must be escaped when used within the value

I am using Tomcat 6.0.33. Any information will be very helpful.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋凉 2024-12-27 15:56:30

也许

-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

有帮助。检查更严格的报价规则。

Maybe

-Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false

helps. Check the more strict quoting rules.

自控 2024-12-27 15:56:30

使用 JSTL forEach 迭代集合。

<c:forEach var="emp" items="${arraylist}">
   <c:out value="{emp.firstName}"/>
</c:forEach>

Use JSTL forEach to iterate the collection.

<c:forEach var="emp" items="${arraylist}">
   <c:out value="{emp.firstName}"/>
</c:forEach>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文