Struts MVCの勉強中です。
以下のエラーが出てきてしまい、原因がわからず困っています。
javax.el.PropertyNotFoundException: Property 'itemName' not found on type java.lang.String
やりたいことは、DBから取得したデータ(List)をJSPに繰り返し表示したいのですが・・・。
どこを直せば良いのでしょうか?
以下にコードを抜粋します。
【Form】
`
public class ItemForm extends org.apache.struts.validator.ValidatorForm implements Iitem {
private String itemName = null; private String price = null; public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public String getItemName() { return itemName; } public void setItemName(String itemName) { this.itemName = itemName; } public itemForm() { super(); }
}
【アクションコントローラ】
public ActionForward mvc(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ItemForm item = (ItemForm) form;
String sql = "Select itemName,price from items order by itemName";
ResultSet rs = SQLC.getData(sql, null);
Collection itemList = new ArrayList();
while (rs.next()) {
String itemName = rs.getString("itemName");
String price = rs.getString("price");
item.setItemName(itemName);
item.setPrice(price);
itemList.add(item.getItemName());
itemList.add(item.getPrice());
}
request.setAttribute("itemList", itemList);
return mapping.findForward(SUCCESS);
}
【JSP】
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。