s:hidden 不渲染实际值
我的 Struts2 表单现在几乎完美地呈现,但 s:hidden 字段仍然无法正常工作。在生成的 HTML 的源代码中,该值被呈现为“id”,而不是实际值。下面是表格。有什么想法吗?
<s:iterator value="bulletins">
<s:if test="approved == false">
<s:form action="ApproveBulletin" method="post">
<table>
<tr>
<td colspan="2"><b>From:</b> <s:property value="name" /></td>
</tr>
<tr>
<td colspan="2"><b>Subject:</b> <s:property value="subject" /></td>
</tr>
<tr>
<td colspan="2"><b>Date:</b> <s:property value="date" /> <br>
</td>
</tr>
<tr>
<td colspan="2"><s:property value="note" />
<s:hidden name="id" value="id" /></td>
</tr>
<tr>
<td><s:submit type="button" value="approve" label="Approve"
action="ApproveBuletin" /></td>
<td><s:submit type="button" value="deny" label="Deny"
action="DenyBulletin" /></td>
</tr>
</table>
<br />
</s:form>
</s:if>
</s:iterator>
My Struts2 form is now rendering almost perfectly, but the s:hidden field is still working incorrectly. In the source code of the generated HTML, the value is being rendered as "id", not the actual value. Below is the form. Any ideas?
<s:iterator value="bulletins">
<s:if test="approved == false">
<s:form action="ApproveBulletin" method="post">
<table>
<tr>
<td colspan="2"><b>From:</b> <s:property value="name" /></td>
</tr>
<tr>
<td colspan="2"><b>Subject:</b> <s:property value="subject" /></td>
</tr>
<tr>
<td colspan="2"><b>Date:</b> <s:property value="date" /> <br>
</td>
</tr>
<tr>
<td colspan="2"><s:property value="note" />
<s:hidden name="id" value="id" /></td>
</tr>
<tr>
<td><s:submit type="button" value="approve" label="Approve"
action="ApproveBuletin" /></td>
<td><s:submit type="button" value="deny" label="Deny"
action="DenyBulletin" /></td>
</tr>
</table>
<br />
</s:form>
</s:if>
</s:iterator>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Struts 标签可能很棘手...我认为您需要使用这样的语法:(
话又说回来,我不完全确定为什么需要
value
属性。您也可以尝试看看如果完全删除它会发生什么。)Struts tags can be tricky... I think you need to use syntax like this:
(Then again, I'm not entirely sure why the
value
attribute is required at all. You might also try and see what happens if you remove it altogether.)只需输入 s:hidden name="id"。不需要 value="id" 名称将被视为值。
just enter as s:hidden name="id". No need of the value="id"The name would be taken as the value.