struts2 s:form 元素修整了action属性中的s:url参数 [英] struts2 s:form element trims the s:url parameter in the action attribute
问题描述
我正在使用 <s:url>
创建一个像 removeAction.action?id=10
这样的 URL, 中的 action 属性应该使用它>
元素.
这里的问题是当
转换为 元素时,我只能看到 action 属性值为
action=/project/removeAction.action"
.id 参数正在被修剪.我想要的结果是 action="/project/removeAction.action?id=10"
<s:param name="id" value="%{id}"/></s:url><s:form action="%{actionUrl}" method="post" enctype="multipart/form-data" ><div><s:file name="imgUpload"/>上传提交>
</s:form>
最近我将 struts2 核心版本升级到 2.3.12,我遇到了这个问题.此问题在 2.3.4.1 版本之后开始
而且我不想使用 hidden
属性来传递参数,因为当上传的文件很大时,此参数会丢失.
有什么解决办法吗?
也许你可以使用通配符映射
</动作>
并将 id 作为它自己的 url 的一部分传递.例如:removeAction/101
参考 http://struts.apache.org/release/2.3.x/docs/wildcard-mappings.html
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.
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>
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
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.
Is there any solution for this?
May be you could use a wildcard mapping
<action name="removeAction\*" class="..">
</action>
And pass the id as part of the url it self.e.g: removeAction/101
Refer http://struts.apache.org/release/2.3.x/docs/wildcard-mappings.html
这篇关于struts2 s:form 元素修整了action属性中的s:url参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!