Action相当于servlet的一部分,它的execute()方法会被struts的入口程序actionServlet调用,完成业务处理。
在struts配置文件里的action里有个input属性,getinputforward()是跳转到input属性的值设定的位置!
<action path="/test"
type="org.apache.struts.webapp.example.TestAction"
name="testForm"
scope="request"
input="testInput">
<forward name="testInput" path="/testInput.jsp"/>
</action>
mapping.getInput()获取的是action中input里的testinput字符串
getInputForward();获取的就是action中input里的testinput,通过testinput又找到forward里这个别名对应的path/testInput.jsp
在struts中有两个类具有findForward方法:
1。 ActionMapping的findForward方法查找的范围是action配置中设定的forward,如下面的两个failure和success:
<action path="/editSubscription"
type="org.apache.struts.webapp.example.EditSubscriptionAction"
attribute="subscriptionForm"
scope="request"
validate="false">
<forward name="failure" path="/mainMenu.jsp"/>
<forward name="success" path="/subscription.jsp"/>
</action>
2。ActionServlet(在action中可以用this.getServlet()来得到)的findForward方法查找的是global-forward中配置的forward,如下
面的三个forward:
<global-forwards>
<forward name="logoff" path="/logoff.do"/>
<forward name="logon" path="/logon.jsp"/>
<forward name="success" path="/mainMenu.jsp"/>
</global-forwards>
Formbean也成表单对象,即上例中的helloform,是对jsp中表单的封装,使得jsp中的域都能使用getter,setter方法获取,抛弃了request.getparramter()方法。Servlet会通过反射调用action的方法。
用户访问*.do的路径时,struts的入口程序actionservlet会查找配置文件,决定交给哪个action来处理。Actionservlet是struts入口servlet,servlet-mapping中把所有url形如*.do的请求都交给它处理。