top of page
  • Writer's pictureOrgLance Technologies LLP

Migrating to Struts2 Version Proper Use of iterator and property Tags

In Struts2 version, the escape attribute is deprecated, and instead, you should use the escapeHtml attribute. Additionally, ensure your iterator tags are properly closed. Here’s how you can write your code to support Struts2 version

Update Dependencies: Ensure your project is using the latest Struts2 dependencies. For Maven, your pom.xml should include:


<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version></version> </dependency>

  1. Using the Struts2 tag library: Make sure your JSP file includes the Struts2 tag library declaration:

<%@ taglib prefix="s" uri="/struts-tags" %>

  1. Using iterator and property tags: Properly close the iterator tag and use escapeHtml attribute with property tag:

<s:iterator value="actionMessages">
    <s:property escapeHtml="false"/>

Here’s the complete code for your JSP snippet:

<%@ taglib prefix="s" uri="/struts-tags" %>

    <title>Struts2 Iterator Example</title>

<h1>Display Action Messages</h1>

<!-- Iterating over action messages and displaying each one without escaping HTML -->
<s:iterator value="actionMessages">
    <s:property escapeHtml="false"/>



  • Dependencies: Ensure you have Struts2 version in your project.

  • Taglib Declaration: Include the Struts2 taglib in your JSP.

  • Iterator and Property Tags: Use <s:iterator> to loop through actionMessages and <s:property escapeHtml="false"/> to render each message without escaping HTML content.

This ensures your JSP code is compatible with Struts2 version and follows the updated usage of attributes in the framework.

0 views0 comments


bottom of page