struts1中mapping.getInputForward()与mapping.getInput()的区别

本文详细介绍了在Struts框架中如何通过ActionForward映射到相应的jsp页面,包括使用Struts配置文件中的<forward>标签进行页面跳转的方法,并提供了具体的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Struts的action中,最后需要return一个ActionForward来从获取Struts文件中的配置项,从而映射到相应的jsp页面

但是,普遍用的都是return mapping.getInputForward("input"),来找到Struts.xml文件中<forward>标签的name属性,该例子用的是input作为name属性的值。


Struts默认的就是input,在<action>标签中进行设值,action标签中有一个名字叫做input的属性,该属性可以直接配置jsp页面的路径,也可以配置参数用来映射<forward>标签的name属性。

如:

1.使用 return mapping.getInputForward("input");

<action name="trustChangePasswordForm" path="/trust/accoreq/changepassword"
type="org.springframework.web.struts.DelegatingActionProxy"
parameter="method" validate="false" scope="request">
<forward name="
input" path="result.jsp" />
</action>


2.使用 return mapping.getInput();

<action name="trustChangePasswordForm" path="/trust/accoreq/changepassword"
type="org.springframework.web.struts.DelegatingActionProxy"
parameter="method" validate="false" scope="request"
input="result.jsp">
</action>

或者:

<action name="trustChangePasswordForm" path="/trust/accoreq/changepassword"
type="org.springframework.web.struts.DelegatingActionProxy"
parameter="method" validate="false" scope="request"
input="changeresult">
<forward name="changeresult" path="result.jsp" />
</action>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值