我想在td中放置一个动态值,在表中有很多td,但是我想将值放在特定的td中

时间:2016-04-07 05:21:33

标签: java html spring

Here is my table where there have a 6 column, in this 6 column I want to place a dynamic value in Rule Id, Rule Name, then two column fill with static value then parameter and value will be fill with dynamic value, I am getting the value but unable to place according to column.

用于创建规则列表的Java类

public class CompArray {
public ArrayList<Rules> a1= new ArrayList<Rules>();

public CompArray (){
    Rules rul = new Rules();
    rul.setruleId("1001");
    rul.setruleName("khagfkj");
    rul.setParameter("lsrkjglkrs");
    rul.setValue("lskdjfk");

a1.add(rul);

}
public ArrayList<Rules> getRules(){

return a1;
}

规则列表控制器

@RequestMapping(value = "/demo", method = RequestMethod.GET)
public String listRules1(ModelMap model) {
CompArray obj1 = new CompArray();
model.addAttribute("listRule1", obj1.a1);
return "hello";
}

html表我希望将动态值放在列中

<c:if test="${not empty listRule1}">
        <table  border ="2">
            <tr>
                <th align="center"><b>Rule ID</b></th>
                <th align="center"><b> Rule Name </b></th>
                <th align="center"><b>Rule Type </b></th>
                <th align="center"><b>Rule Validity </b></th>
                <th align="center"><b>Parameter </b></th>
                <th align="center"><b>Value</b></th>
            </tr>

 <c:forEach items="${listRule1}" var="obj1">
                <tr>
                    <td>${obj1.id}</td>
                    <td>${obj1.details}</td>
                    <td>${obj1.parameter}</td>
                    <td>${obj1.value}</td>

                </tr>                           
            </c:forEach>

   </table></c:if>

如何将动态值放在特定列中? 请有人帮我做这个..我尝试了很多解决方案,但无法解决这个问题。

1 个答案:

答案 0 :(得分:0)

再添加两个tds,如下所示。

<td>${obj1.id}</td> 
<td>${obj1.details}</td>
<td></td>
<td></td> 
<td>${obj1.parameter}</td> 
<td>${obj1.value}</td>