如何在Struts2中格式化表格? [英] How to format a table in Struts2?

查看:137
本文介绍了如何在Struts2中格式化表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以显示顶部的四个标题和其下的所有字段的方式对其进行格式化。

I need to format it in a way that show the four headers on the top and all the fields under them. but it creates extra tds and trs.

 <form name="edit" method="POST" action="edit">
          <table border="4">
              <thead><tr>
                      <td>Field1</td><td>Field2</td><td>Field3</td<td>Field4</td>            
                     </tr>
              </thead>
              <tbody>
                <s:iterator value="basket.items" var="item" status="element">
                  <tr>
                    <td> <s:textfield type="hidden" id="item[%{#element.index}].id"
                                        name="item[%{#element.index}].id" value="%{id/></td>
                    <td> <s:textfield id="item[%{#element.index}].product.price" 
                                        name="item[%{#element.index}].product.price" value="%{product.price}" /></td>
                    <td> <s:label value="%{product.name}"/></td>

                    <td> <s:label value="%{time}"/> </td>

                    <td> <s:label value="%{date}"/>    </td>

                    <td> <s:textfield name="item[%{#element.index}].product.price2" 
                                       id="item[{#element.index}].product.price2" value="%{product.price2}"/></td>
                 </tr>
               </s:iterator>
             </tbody>
       </table> 
   <input id="edit" type="submit" name="action" value="Edit"/>
 </form>

HTML

    <form name="edit" method="POST" action="edit">
          <table border="4">
                <thead><tr>
                         <td>Field1</td><td>Field2</td><td>Field3</td<td>Field4</td>            
                       </tr>
               </thead>
                <tbody>    
                        <tr>
                            <td>  <tr>
                               <td class="tdLabel"></td>
                            <td><input type="hidden" name="item[0].id" value="16" 
                                                     id="item[0].id"/></td>
                       </tr>
                       </td>
                       <td><tr>
                              <td class="tdLabel"></td>
                      <td><input type="text" name="item[0].product.price" 
                                             value="55"      
                                             id="item[0].product.price"/></td>
                      </tr>
                      </td>
                      <td><tr>
                          <td class="tdLabel"></td> 
                               <td><label id="">Product1</label></td>
                      </tr></td>
                      <td><tr>
                           <td class="tdLabel"></td>
                           <td><label id="">9:31:03 AM</label></td>
                      </tr>
                      </td>
                      <td><tr>
                           <td class="tdLabel"></td>
                           <td><label id="">2013</label></td></tr>
                      </td>
                      <td><tr>
                           <td class="tdLabel"></td>
                           <td><input type="text" name="item[0].unit.price2" 
                                      value="1000.0"  
                                      id="item[0].unit.price2"/>              

                            </td>
                      </tr>
                      </td>
                      </tr>

                </tbody>
            </table> 


推荐答案

只要移除额外的内容和格式,切换到简单主题。

Just remove the extra stuff and format as you like by switching to simple theme.

例如

<s:textfield name="name" theme="simple"/>

现在不会创建任何额外的TR或TD。

Now it won't create any extra TRs or TDs.

这篇关于如何在Struts2中格式化表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆