Java springboot に関して、
以下のエラーから抜け出せません。
Invalid property '0' of bean class [com.example.web.ShoppingForm]: Bean property '0' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
翻訳では
Beanクラス[com.example.web.ShoppingForm]の無効なプロパティ '0':Beanプロパティ '0'は読み取り不可能であるか、または無効なgetterメソッドを持っています:getterの戻り型がsetterのパラメータ型と一致していますか?
となっています。
・フォームクラス
public class ShoppingForm {
private List<String> itemList;
public ShoppingForm() {} public List<String> getItemList() { return itemList; } public void setItemList(List<String> itemList) { this.itemList = itemList; }
}
・コントローラー
@Controller
@RequestMapping("/shopping")
public class ShopprngContriller {
@Autowired private ShoppingService service; @Autowired private ServletContext app; @ModelAttribute private ShoppingForm setUpFrom() { return new ShoppingForm(); } @RequestMapping("/") public String shopping(ShoppingForm form) { List<String> list = new ArrayList<String>(); list.add("item1"); list.add("item2"); list.add("item3"); form.setItemList(list); app.setAttribute("form", form); return "items"; }
・翻訳を読む限りFromクラスに問題がありそうですが、springのFromクラスとして適切でない作成をしてしまっているのでしょうか?
・リストのデータを持ったままitem.jspへ進みたいです。
よろしくお願いします。