Search code examples
jspstruts2

Possible issues for not working Struts 2 application properly


I am new to Struts 2. Its initial release was in 2006. So when I followed a few login examples using struts 2, they did not work for many reasons. Since I was new to Struts 2, it was more difficult to find reasons for those issues. So I'm going to share some of the reasons why the Struts 2 application may not work properly. If I mention some wrongs, please be kind enough to correct them and if you know the reasons other than that, it's better to add them as answers. Thank you.


Solution

  • 1. When add dependencies

    Don't add all the dependencies. Remember to add essential dependencies only.

    enter image description here

    Follow this link to download dependencies http://struts.apache.org/download.cgi

    2. Check the struts 2 version in struts.xml file.

    I used struts 2.5.26. So I changed the version as 2.5 . IF you use struts 2.3.37, you should change it to 2.3

     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
     
     "http://struts.apache.org/dtds/struts-2.5.dtd">
    

    3. Change filter package of web.xml file according to the version of struts 2

    Changed filter package in Struts >= 2.5

       <filter-name>struts2</filter-name>
                <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter   </filter-class>
    

    Changed Filter Structure in Struts >= 2.1.3

       <filter-name>struts2</filter-name>
                <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    

    For more details https://struts.apache.org/core-developers/web-xml.html

    I created my struts 2 application as a dynamic web project. As well as we can create struts 2 project as a maven project also.