struts-1.3.10中的<action-mappings> <action>标签中<set-property>的用法

 <action path="/prepareValidator"
                type="examples.SuccessAction">
            <forward name="success" path="/jsp/validator/Validator.jsp"/>
        </action>

        <action path="/processValidator"
                type="examples.validator.ProcessValidatorAction"
                name="validatorForm"
                scope="request"
                input="/jsp/validator/Validator.jsp"
                cancellable="true"               
                validate="true">
            <set-property property="actionId" value="validatorAction"/>
            <forward name="success" path="/jsp/validator/ValidatorResults.jsp"/>
        </action>

这是在struts-config.xml中的配置一个Action

这是对应的表单

<html:form action="validatorAction" method="get">

	<table>
	<tr><td>Byte:</td><td><html:text property="byteValue" /> -128 .. 127</td></tr>
	<tr><td>Short:</td><td><html:text property="shortValue" /> -32768 .. 32767</td></tr>
	<tr><td>Integer:</td><td><html:text property="integerValue" /> -2147483648 .. 2147483647</td></tr>
	<tr><td>Long:</td><td><html:text property="longValue" /> -9223372036854775808 .. 9223372036854775807</td></tr>
	<tr><td>Float:</td><td><html:text property="floatValue" /> 1.4E-45 .. 3.4028235E38</td></tr>
	<tr><td>Double:</td><td><html:text property="doubleValue" /> 4.9E-324 .. 1.7976931348623157E308</td></tr>
	<tr><td>Credit Card:</td><td><html:text property="creditCard" /> e.g. 4444333322221111 (no spaces) </td></tr>
	<tr><td>Date:</td><td><html:text property="date" /> mm/dd/yyyy</td></tr>
	<tr><td>Email:</td><td><html:text property="email" /></td></tr>
	<tr><td>Mask:</td><td><html:text property="mask" /> US zip code e.g. 90210</td></tr>
	<tr><td>Min Length:</td><td><html:text property="min" /> (minimum 5 characters)</td></tr>
	<tr><td>Max Length:</td><td><html:text property="max" /> (maximum 10 characters)</td></tr>
	<tr><td>Range:</td><td><html:text property="range" /> 100 .. 1000</td></tr>
	<tr><td>* Required:</td><td><html:text property="required" /></td></tr>
	</table>
	<p>These two fields must contain the same value:</p>
	<table>
	<tr><td>* Password:</td><td><html:password property="password" redisplay="false"/> (minimum 5 characters)</td></tr>
	<tr><td>* Password confirmation:</td><td><html:password property="password2"  redisplay="false"/></td></tr>
	</table>

	<hr noshade="noshade" />   
	<p>
		<html:submit>
			<bean:message key="button.submit" />
		</html:submit>
		<html:cancel/>
	</p>
</html:form>

这个表单的action是validatorAction,但是显出的页面确实提交到/processValidator.do,这就是set-property标签其的作用,在<html:form/>这个标签中,action的路径寻找是这样的写的:

The URL to which this form will be submitted. This value is also used to select the ActionMapping we are assumed to be processing, from which we can identify the appropriate form bean and scope. If a value is not provided, the original URI (servletPath) for the request is used.


就是选择ActionMapping对应的Action来处理,set-property 标签的作用就是设置ActionMapping的ActionID属性,让processValidator这个Action对应到ActionMapping的ActionID属性,所以在寻找Action路径来处理这个Form表单的时候就是选择ActionID为validatorAction的Action,就是processValidator这个Action

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值