1. Create a project first
2. Create a JSP in Webroot, called index.jsp, to write a sentence inside
<body> Hello struts2 <br> </body>
3. Writing code in the background
public class T {Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter f;}
4. Write in Struts.xml
<constant name= "Struts.devmode" value= "true"/> <package name= "Default" namespace= "/" extends= " Struts-default "> <action name=" hell "> <result> /hello.jsp </result> </action> </package>
5. Writing in Web. xml
<filter> <filter-name>struts2</filter-name> <filter-class> Org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter</filter-class> </filter>
Attention:
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
This sentence is very important oh, can be said to play a decisive role, do not forget OH
Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter