有没有办法用 Struts 填充多个表单并使它们对 JSP 页面可用?
我正在构建一个页面,上面有两种不同的表单,需要从数据库中预填充自定义数据。两种形式必须在同一页上。
最佳答案
是的,这是可能的。
您可以为此问题指定多个 ActionForm
实现(首选)或仅使用一个 - 无论如何。
<nested:root name="myFirstForm">
<nested:form action="/MyAction.do?method=foo" method="post">
<%-- some code --%>
</nested:form>
<nested:form action="/MyAction.do?method=bar" method="post">
<%-- some code --%>
</nested:form>
</nested:root>
<nested:root name="mySecondForm">
<nested:form action="/MyAction.do?method=foobar" method="post">
<%-- some code --%>
</nested:form>
</nested:root>
来自 Apache Struts Newbie FAQ :
Q: Do I have to have a separate ActionForm bean for every HTML form?
A: This is an interesting question. As a newbie, it is a good practice to create a new ActionForm for each action sequence.
关于java - 在 Struts 1.x JSP 中填充多个表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15297587/