struts2.xml配置了defaultStack时action中定义的字段无法接收值的解决方法

我的xml配置如下:

<action name="saveOrUpdateZcfg" class="com.zcfg.action.ZcfgAction" method="saveOrUpdateZcfg">
	<interceptor-ref name="paramsPrepareParamsStack" />
	<interceptor-ref name="defaultStack">
		<!-- 配置允许上传的文件类型,多个用","分隔 -->
		<param name="fileUpload.allowedTypes">
			application/msword,application/pdf,application/zip,application/x-zip-compressed
		</param>
		<!-- 配置允许上传的文件大小,单位字节 -->
		<param name="fileUpload.maximumSize">10485760</param>
	</interceptor-ref>
</action>



解决方法:
配置了defaultStack时,paramsPrepareParamsStack一定要配置在defaultStack之前,否则action中定义的字段无法接收值。


-------------------------------------------------------------------------------------------------------------


下面是各个栈的拦截器:defaultStack的参数modelDriven之后,而paramsPrepareParamsStack会先拦截params。

<interceptor-stack name="defaultStack">
	<interceptor-ref name="exception"/>
	<interceptor-ref name="alias"/>
	<interceptor-ref name="servletConfig"/>
	<interceptor-ref name="i18n"/>
	<interceptor-ref name="prepare"/>
	<interceptor-ref name="chain"/>
	<interceptor-ref name="debugging"/>
	<interceptor-ref name="scopedModelDriven"/>
	<interceptor-ref name="modelDriven"/>
	<interceptor-ref name="fileUpload"/>
	<interceptor-ref name="checkbox"/>
	<interceptor-ref name="multiselect"/>
	<interceptor-ref name="staticParams"/>
	<interceptor-ref name="actionMappingParams"/>
	<interceptor-ref name="params">
	  <param name="excludeParams">dojo\..*,^struts\..*</param>
	</interceptor-ref>
	<interceptor-ref name="conversionError"/>
	<interceptor-ref name="validation">
	    <param name="excludeMethods">input,back,cancel,browse</param>
	</interceptor-ref>
	<interceptor-ref name="workflow">
	    <param name="excludeMethods">input,back,cancel,browse</param>
	</interceptor-ref>
</interceptor-stack>
<interceptor-stack name="paramsPrepareParamsStack">
	<interceptor-ref name="exception"/>
	<interceptor-ref name="alias"/>
	<interceptor-ref name="i18n"/>
	<interceptor-ref name="checkbox"/>
	<interceptor-ref name="multiselect"/>
	<interceptor-ref name="params">
	    <param name="excludeParams">dojo\..*,^struts\..*</param>
	</interceptor-ref>
	<interceptor-ref name="servletConfig"/>
	<interceptor-ref name="prepare"/>
	<interceptor-ref name="chain"/>
	<interceptor-ref name="modelDriven"/>
	<interceptor-ref name="fileUpload"/>
	<interceptor-ref name="staticParams"/>
	<interceptor-ref name="actionMappingParams"/>
	<interceptor-ref name="params">
	    <param name="excludeParams">dojo\..*,^struts\..*</param>
	</interceptor-ref>
	<interceptor-ref name="conversionError"/>
	<interceptor-ref name="validation">
	    <param name="excludeMethods">input,back,cancel,browse</param>
	</interceptor-ref>
	<interceptor-ref name="workflow">
	    <param name="excludeMethods">input,back,cancel,browse</param>
	</interceptor-ref>
</interceptor-stack>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值