2013-07-26 45 views
1

我填寫表格,數據在prices.jsp頁這樣錯誤來填充數據表

<tbody> 
<c:forEach items="${listrooms}" var="listrooms"> 
<tr> 
    <td>${listrooms.getClassId()}</td> 
    <td>${listrooms.getBeds()}</td> 
    <td>${listrooms.getPrice()}</td> 
</tr> 
</c:forEach> 

從列表中的數據,我從行動得到

session.setAttribute("listrooms", roomService.getRooms()); 
return "prices"; //redirect to page 

listrooms是not null(我使用調試器進行了檢查),它包含Room對象,其中有方法getClassId(),getBeds(),getPrice()。但我有一個錯誤

The function getClassId must be used with a prefix when a default namespace is not specified

有什麼不對?

+1

嘗試$ {} listrooms.classId所以 – DaveH

回答

1

訪問bean屬性的語法是錯誤的。如果你的bean說A有一個像getB() getter方法,您可以使用EL作爲${A.b}訪問...

你的情況

因此您的代碼更改爲:

<td>${listrooms.classId}</td> 

其中getClassId()應是公共的getter豆的方法Room

同樣:

<td>${listrooms.beds}</td> 
<td>${listrooms.price}</td> 
+0

一些領域和getter和setter他們每類是一個bean? – lapots

+0

並不是每個人都可以參考Java bean規範來了解什麼是bean。請參閱我已鏈接的標記wiki! – NINCOMPOOP

+0

那麼我的對象沒有實現可序列化,並沒有寫入默認的contstructor。但是我可以像豆一樣使用它? – lapots