按值

时间:2016-11-01 07:16:51

标签: java arrays jsp html-table jstl

我有两个阵列:

<%String TXTfileArray[] = (String[])request.getAttribute("txt");%>    
<%String sentenceArray[] = (String[])request.getAttribute("sentence");%>

使用以下内容:

<body>

<h1>Table of Phone Numbers</h1>
<table border="1">

 <tr>
    <th>txt name</th>
    <th>sentence</th>
  </tr>

   <% for (int i=0; i< sentenceArray.length;i++){ %>

  <tr>
    <td> <%=TXTfileArray[i] %>  </td>    
     <td> <%=sentenceArray[i] %>  </td>   <%} %> 

   </tr>


 </table>
</body>

我可以得到结果:

the result i got

所以如何更改表,因为表中有重复的txt名称,如何删除重复的txt名称。在列中保留唯一的txt名称(例如合并单元格)

我想得到如下结果。

enter image description here

如果可以更改输出,如何在JSTL标签中执行此操作?

2 个答案:

答案 0 :(得分:-1)


检查以下代码。它可能有助于满足您的要求。

JSBin链接:https://jsbin.com/?html,output

is to make all the fields in BeanA private, and only access them via getter setters.
This approach, however, requires a lot of modification of the original code (e.g. the BeanA class). 

答案 1 :(得分:-2)

使用HTML&lt; td&gt; rowspan属性指定单元格应跨越的行数。

E.g.:

<table border="1">
  <tr>
    <th>txt name</th>
    <th>sentence</th>    
  </tr>
  <tr>
    <td>txt1</td>
    <td>apple from one</td>   
  </tr>
  <tr>
    <td rowspan="3">txt6</td>
    <td>six trees</td>
  </tr>
 <tr>        
    <td>cats</td>
  </tr>
 <tr>    
    <td>happy dogs</td>
  </tr>
</table>