Setting Up a Struts 2 Project

Site Admin · 11 Sep 2026 · 4 views

Required JARs

A Struts 2 web app needs the core jars: struts2-core, xwork-core, ognl, freemarker, commons-fileupload, commons-io and commons-logging.

Struts 2 library jars

Web Project Steps

  1. Create a Dynamic Web Project in Eclipse.
  2. Add the Struts 2 jars to WEB-INF/lib.
  3. Configure web.xml with the Struts 2 filter.
  4. Create struts.xml in the classes/src folder.
  5. Write an Action class and JSP views.

Creating the dynamic web project

Adding Struts jars to the project

Browsing for the Struts jars

web.xml Filter Mapping

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Deploying on Tomcat

Key Points

  • Deploy the WAR to Tomcat and hit action URLs.
  • struts.xml maps actions to classes and results.
  • All jars belong under WEB-INF/lib.
Share this post:

Comments (0)

Please login or register to comment.