実現したいこと(画面操作の流れ)
・操作1.画面aで検索を実行、検索結果の一覧を表示
・操作2.一覧上から任意のデータを選択すると当該データの詳細情報を閲覧できる画面bに遷移
困ってるポイント
画面aから画面bに遷移する際に500エラーが発生。
モデルに詰め込んだ値を画面で受け取ることに失敗する。
※Java、Springフレームワークを用いています。
プログラムの該当箇所
不足があればお手数をおかけしますがご指摘くださいませ。
コントローラー
java
1package practice.component.controller; 2 3import org.springframework.beans.factory.annotation.Autowired; 4import org.springframework.stereotype.Controller; 5import org.springframework.web.bind.annotation.PathVariable; 6import org.springframework.web.bind.annotation.RequestMapping; 7import org.springframework.web.bind.annotation.RequestMethod; 8import org.springframework.web.servlet.ModelAndView; 9import practice.component.repository.GoodsDao; 10import practice.entity.GoodsModel; 11 12@Controller 13public class GoodsDetailController { 14 @Autowired 15 private GoodsDao goodsDao; 16 17 public GoodsDetailController() { 18 super(); 19 } 20 21 @RequestMapping(value="/goods/detail_{productId}.do",method = RequestMethod.GET, produces="text/plain;charset=UTF-8") 22 public ModelAndView detailView(@PathVariable("productId") String productId) { 23 GoodsModel goodsModel = this.goodsDao.getGoods(productId); 24 25 ModelAndView modelAndView = new ModelAndView("goods/detail", "goods", goodsModel); 26 return modelAndView; 27 } 28 } 29
モデル
Java
1package practice.entity; 2public class GoodsModel { 3 /** 商品ID */ 4 private String productid; 5 /** 商品名 */ 6 private String productname; 7 /** 値段 */ 8 private String price; 9 10 public String getProductid() { 11 return productid; 12 } 13 public void setProductid(String productid) { 14 this.productid = productid; 15 } 16 public String getProductname() { 17 return productname; 18 } 19 public void setProductname(String productname) { 20 this.productname = productname; 21 } 22 public String getPrice() { 23 return price; 24 } 25 public void setPrice(String price) { 26 this.price = price; 27 } 28}
画面
JSP
1<body> 2<div class="main"> 3 <div class="errorArea">${goods.errorMsg}</div> 4 <form action="detail_{productId}.do" method="POST"> 5 <table class="productTable"> 6 <tr> 7 <td class="header">商品ID</td> 8 <td class="data"><input type="text" value="${goods.productId}" name="productId" class="input"/> </td> 9 </tr> 10
エラー内容
例外
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:626)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)根本原因
javax.el.PropertyNotFoundException: プロパティ[productId]がタイプ[practice.entity.GoodsModel]で見つかりません
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:260)
javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:212)
javax.el.BeanELResolver.property(BeanELResolver.java:333)
javax.el.BeanELResolver.getValue(BeanELResolver.java:92)
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:125)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:701)
org.apache.jsp.WEB_002dINF.views.goods.detail_jsp._jspService(detail_jsp.java:149)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
何卒宜しくお願いいたします。
あなたの回答
tips
プレビュー