seorinha / Mountain

0 stars 0 forks source link

review 구현 #13

Open seorinha opened 7 months ago

seorinha commented 7 months ago

~25 토

seorinha commented 7 months ago

리뷰 작성 구현 시 서버로 안넘어가고 500에러

592 ERROR [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]] Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "javax.servlet.http.HttpSession.getAttribute(String)" is null] with root cause

java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "javax.servlet.http.HttpSession.getAttribute(String)" is null

    at com.project.review.ReviewRestController.create(ReviewRestController.java:29)

비로그인 상태 때문같아서 로그인 상태로 시도 해봐도 똑같은 에러

ReviewRestController의 session에서 id를 꺼낼 때 int 를 Integer로 수정해서 시도해보니

java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because "mtId" is null

    at com.project.review.ReviewRestController.create(ReviewRestController.java:34)

mtId가 null인데 int 변수에 담으려고 해서 NPE 에러 발생 (int는 null일 수가 없다)

-> session에 mtId가 담기지 않아서 라고 판단했고 mtId = info테이블의 id 이기 때문에 Domain.Info 생성한 후 reviewRestController에 Info의 instance 만들고 id를 설정했다

seorinha commented 7 months ago

mountain.jsp에서 EL문법 적용안됨

seorinha commented 7 months ago

mountain-review-list 화면에서 review 목록들을 가져오는건 해결됐지만 각 리뷰에 mtId가 지정되지 않고 저장 되어서 모든 리뷰가 나타남 리뷰 insert시 mtId 지정?