有没有办法用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.