jsp獲取一個對象和list對象

DiscHd ks = DiscHdService.getDiscHdByID(code);
model.addAttribute("ks", ks);jsp

若是傳的是對象,則jsp頁面直接用"${ks.DValue}"獲得值。spa

 

 

List<DiscDet> discDets=discDetService.getDiscDetByCode(code);
// System.out.println("discDets的數據爲: "+discDets.get(0).getDValue()+","+discDets.get(0).getType()+","+discDets.get(0).getDOpen()+","+discDets.get(0).getDetail());
for(int i=0;i<discDets.size();i++){System.out.println(discDets.get(i).getType().equals("DHDC"));
if(discDets.get(i).getType().equals("DHDC")){
System.out.println(discDets.get(i).getType());
List<DiscDet> DHDC=new ArrayList<DiscDet>();
DHDC.add(discDets.get(i));
System.out.println(DHDC.get(0).getDValue()+"@@@@@@@@@@@@");
model.addAttribute("DHDC",DHDC);
}
}code

 

若是傳的是list,則jsp頁面<c:forEach>獲得值對象

<c:forEach items="${DHDC}" var="DHDC">
<input type="hidden" id="sss" name="sss" value="${DHDC.DValue}"/>
</c:forEach>get

相關文章
相關標籤/搜索