2016-04-06 46 views
1

我在下面共享一個圖像,顯示我具有id,細節,參數和值的列表值。我可以填寫ID和詳細信息,但未能填寫參數和值。如何填充具有動態值的特定td

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> 

誰能告訴這個問題怎麼能解決嗎? 非常感謝您爲您提供的建議和幫助。

+0

請我需要幫助做到這一點,請大家幫忙有人幫我 –

回答

0

嘗試使用not empty inatead的!empty toverify這樣的,如果條件:

<c:if test="${ not empty listRule1}"> 
+0

我這樣做,我得到一個值,但我如何將它們放在確切的td中,你能幫我做到這一點 –

+0

嘗試添加CompArray obj1 = new CompArray();在List list = new ArrayList()中; list.add(obj1); model.addAttribute(「listRule1」,list); – Abdelhak