这是我的代码:
<s:iterator value="ChapterTreeList" id="chapterTree">
...
<s:url
id="deployChaptersUrl"
action="ajaxDeployChapter"
includeContext="false">
<s:param
name="nodeId"
value="%{#chapterTree.nodeId}"/>
</s:url>
<s:form
id="deployChapters%{#chapterTree.nodeId}"
action="%{deployChapterUrl}"
theme="simple"
method="POST">
</s:form>
...
</s:iterator>
我希望下面有多个这样的表格:
<form
id="deployChapters27623"
name="deployChapters27623"
action="/path/to/ajaxDeployChapter.action?nodeId=27623" <-- nodeId here
method="POST">
</form>
但我会得到这样的表格:
<form
id="deployChapters27623"
name="deployChapters27623"
action="/path/to/ajaxDeployChapter.action" <-- nodeId is missing here
method="POST">
</form>
Struts 2.3.15.1
答案 0 :(得分:2)
POST
HTTP方法将参数发送到请求正文中。这是支持查询字符串中的参数的POST
和GET
之间的差异。
所以,你甚至不应该尝试将查询字符串作为POST的一部分发送。无论如何它都行不通。如果您需要发送nodeId
,则有2个选项;
/path/to/ajaxDeployChapter.action/27623
。nodeId
并填充其值。 答案 1 :(得分:1)
我之前没有使用Struts,但是我会冒险猜测。
<s:form
id="deployChapters%{#chapterTree.nodeId}"
action="%{deployChapterUrl}"
theme="simple"
method="POST">
</s:form>
应该这样吗?
<s:form
id="deployChapters%{#chapterTree.nodeId}"
action="%{deployChapterUrl}?%{#chapterTree.nodeId}"
theme="simple"
method="POST">
</s:form>
答案 2 :(得分:1)
以下是我解决问题的方法:
<s:form
id="deployChapters%{#chapterTree.nodeId}"
action="%{deployChapterUrl}"
theme="simple"
method="POST">
<s:hidden name="nodeId" value"%{#chapterTree.nodeId}" />
</s:form>