java - 在 Struts 1.x JSP 中填充多个表单

标签 java jsp struts struts-1

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

相关文章:

java - 员工数据库程序的 ArrayIndexOutOfBounds 异常

java - BeanFactory实现

java - 它的用途 <sf :errors path ="" cssClass ="error"> in jsp?

java - 我应该将 Struts 1 或 2 与 jQuery 一起使用吗?

java - 如何向 JFrame 添加多个不同大小的 JPanel

java - 无法使用 jquery 和 java 在 fullcalendar 仪表板中显示日历事件

java - 将字符串写入文件,用户从 &lt;input type ="file"> 中选择

java - 如何在 JSF 中替换 JSP org.springframework.security 导入?

java - 在 javascript arraylist 中转换 java 对象列表

jsp - 相当于Struts 1.x "bean:define"标签?