【问题标题】:Spring MVC Table selected rowSpring MVC 表选择行
【发布时间】:2011-02-15 21:51:38
【问题描述】:

在 Spring MVC 2.5 应用程序中,我使用 spring <form:form> 组件,并以这种形式呈现带有 c:forEach 的表格。

在每一行中都有一个提交按钮。如果我通过单击一个按钮开始提交,我想知道哪个按钮处理了提交。

<form:form commandName="formObject">
<table class="data-table" cellpadding="1" cellspacing="1" border="0">
  <thead>
   <tr>
   </tr>
  </thead>
  <c:forEach items="${list}" var="document" varStatus="row">
    <tr>
      <td>  
        <input type="submit"  value="${document.title}"/>
      <td>
    </tr>
  </c:forEach>
</table>
</form:form>

谢谢。

【问题讨论】:

    标签: model-view-controller spring forms controller


    【解决方案1】:

    为提交按钮命名。您可以像处理任何其他参数一样处理来自该按钮的请求参数。不过,某些浏览器可能会以不同的方式处理它们给出的值。

    <input name="submittype" type="submit" value="${document.title}" />
    

    【讨论】:

    • 仍然比使用 JavaScript hack(这通常是建议的方式)更好
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多