struts-1.3.10中的 标签中的用法

 <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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章