struts中的findForward()和getinputforward()

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的请求都交给它处理。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值