struts2 s:form元素会修剪action属性中的s:url参数 [英] struts2 s:form element trims the s:url parameter in the action attribute

查看:52
本文介绍了struts2 s:form元素会修剪action属性中的s:url参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用<s:url>创建类似removeAction.action?id=10的URL,该URL应该由<s:form>元素中的action属性使用.

I am using <s:url> to create a URL like removeAction.action?id=10 which should be used by the action attribute in the <s:form> element.

这里的问题是,当<s:form>转换为<form>元素时,我只能看到action属性值为action="/project/removeAction.action". id参数被修整.我想要的结果是action="/project/removeAction.action?id=10"

The issue here is when the <s:form> converts to <form> element I can only see the action attribute value as action="/project/removeAction.action". The id parameter is getting trimmed. The result I wanted is action="/project/removeAction.action?id=10"

<s:url var="actionUrl" action="removeAction" includeContext="false">
  <s:param name="id" value="%{id}" /> 
</s:url>

<s:form action="%{actionUrl}" method="post" enctype="multipart/form-data" >
 <div>
  <s:file name="imgUpload"/>
  <s:submit> upload </submit>
 </div>
</s:form>

最近我将struts2核心版本升级到2.3.12,并且遇到了这个问题.此问题在2.3.4.1版本之后开始

Recently I upgrade the struts2 core version to 2.3.12 and I am getting this issue. This issue starts after version 2.3.4.1

我不想使用hidden属性来传递参数,因为当文件大小较大时,该参数会丢失.

And I don't want to use a hidden attribute to pass the parameter as this parameter get lost when the file size is big to upload.

有什么解决办法吗?

推荐答案

也许您可以使用通配符映射

May be you could use a wildcard mapping

<action name="removeAction\\*" class="..">

</action>

并将ID作为自身URL的一部分传递,例如:removeAction/101

And pass the id as part of the url it self.e.g: removeAction/101

请参阅 http://struts.apache.org/release /2.3.x/docs/wildcard-mappings.html

这篇关于struts2 s:form元素会修剪action属性中的s:url参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆