如何用动态值填充特定的td

时间:2016-04-06 13:17:05

标签: java html spring

我正在共享下面的图片,显示我有id,详细信息,参数和值的列表值。我可以填写id和详细信息,但无法填写参数和值。

i am shearing an image that shows i have a list value for id, details,parameter,values, i am able to fill the id & details, but failed to fill parameter & value.

下面是用于创建传递给控制器​​的列表的 java类。我得到了价值但不能在td中显示:

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

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

    a1.add(rul);

 }
public ArrayList<Rules> getRules(){

    return a1;
}

控制器

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

HTML

  <c:if test="${!empty listRule1}">
            <table  border ="2">
                <tr>
                    <th align="center"><b>Rule ID</b></th>
                    <th align="center"><b> Rule Details </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)

尝试使用not empty的{​​{1}} inatead来验证if条件,如下所示:

!empty