The first step is to create a new Web project, add jsp,login.jsp and result.jsp, and note that the form's action attribute is "*.action"
The second step, will be 5 struts of the package (Commons-logging-1.0.4.jar,freemarker-2.3.8.jar,ognl-2.6.11.jar,struts2-core-2.0.12.jar, Xwork-2.0.6.jar), copied to Web-inf/lib
Step three, create two XML, a web.xml, add content:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
A struts.xml is added below SRC, which reads:
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Struts Public
"-//apache Software foundation//dtd Struts Configuration 2.0//en"
"Http://struts.apache.org/dtds/struts-2.0.dtd" >
<struts>
<package name= "EA" extends= "Struts-default" >
<action name= "Login" class= "Com.test.action.LoginAction" >
<result name= "a" >/result.jsp</result>
</action>
</package>
</struts>
Step fourth, set up the Action,com.test.action.loginaction class, with two properties consistent with the page name (note that there is no need for a name to correspond to the page, only the Set,get method is required for the page name), The action class has an Execute method that returns a page
for the name of the corresponding value of result.