且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何对齐两个提交按钮?

更新时间:2022-12-11 13:31:47

页面上没有必要提供两种表单来提交不同的操作(方法)。

It's not necessary to have two forms on the page to submit different actions (methods).

从一开始,Struts就有一种技巧来分配提交按钮到不同的操作。在最新版本中,它通过 submit 标签执行,用于从属性(例如 action )构建操作URL >或方法

Since the beginning, Struts has a technique to dispatch submit buttons to different actions. In the latest version it's performed via the submit tag, that is used to build the action URL from the attributes such as action or method.

由于您在表单上使用简单主题标签,它继承到所有输入字段。没有必要单独应用相同的主题。

As you are using a simple theme on the form tag, it's inherited to all input fields. It's not necessary to apply the same theme individually.

如果您使用 table HTML标记来设计表单元素,记录 tr 标记具有 white-space:nowrap; CSS样式。例如

If you are using a table HTML tag to design your form elements it's substantial to put these buttons inside the same record tr tag having white-space:nowrap; CSS style. For example

<s:form  name="regform" id="regform" theme="simple">
<table style="width:100%;" cellspacing="0" cellpadding="0" border="0">
  <tr style="white-space:nowrap;">
    <td style="width:50%;" valign="top" align="right" >
        <s:submit action="download2" value="View coc2"/>
    </td>
    <td style="width:50%;" valign="top" align="right" >
        <s:submit action="download1" value="View coc1"/>
    </td>
  </tr>
<table>
</s:form>

要使操作 this 答案,了解如何在 struts.xml中启用操作前缀能够使用 s:submit 标签的 action 属性。

To have the action attribute being worked see this answer to learn how to enable an action prefix in struts.xml to be able to use action attribute of the s:submit tag.