개발

Java JSP오류 | javax.el.PropertyNotFoundException: Property '0' not found on type java.lang.String

AM0530 2020. 4. 29. 15:30

1. 오류 내용 : javax.el.PropertyNotFoundException: Property '0' not found on type java.lang.String

2. 오류 원인 :  varStatus="status" 를 설정한 항목에도 [status.index] 를 추가함

 

(작성한 코드 = 오류가 발생한 코드)

<c:forEach var="listC" items="${listC}">
	<c:set var="subject" value="${fn:split(listC.subject, '∮')}" />
	<c:set var="subject_contents" value="${fn:split(listC.subject_contents, '∮')}" />
	<c:forEach var="subject_no" items="${fn:split(listC.subject_no, '∮')}" varStatus="status"> 
    	<tr>
			<td>${subject_no[status.index]}</td>
			<td>${subject[status.index]}</td>
			<td>${subject_contents[status.index]}</td>
		</tr>
	</c:forEach>
</c:forEach> 

 

line4에서 var="subject_no"에 varStatus="status" 를 추가했는데 

line6에서 또 <td>${subject_no}</td>에 [status.index]를 추가해서 오류발생 

 

3. 해결 : varStatus="status" 를 추가한 var="subject_no"를 쓰는 항목은[status.index]제거

 

(해결한 코드 = 오류없이 정상 동작하는 코드) 

<c:forEach var="listC" items="${listC}">
	<c:set var="subject" value="${fn:split(listC.subject, '∮')}" />
	<c:set var="subject_contents" value="${fn:split(listC.subject_contents, '∮')}" />
	<c:forEach var="subject_no" items="${fn:split(listC.subject_no, '∮')}" varStatus="status"> 
		<tr>
			<td>${subject_no}</td>
			<td>${subject[status.index]}</td>
			<td>${subject_contents[status.index]}</td>
	</tr>
	</c:forEach>
</c:forEach> 

기준점이 되는 항목(subject_no)에 varStatus를 추가하고 기준점이 되는 항목(subejct_no)를 사용할때는 

[status.index]를 빼고 사용한다. 

물론 같이 forEach로 표출할 내용 (subject, subject_contents)는 [status.index]를 추가한다. 

 

4. 참고 : varStatus로 forEach를 돌릴 항목을 가져올때는 

배열또는 List형식으로 가져와야 한다. 

 

(참고) https://stackoverflow.com/questions/10592156/property-0-not-found-on-type-java-lang-string

 

Property '0' not found on type java.lang.String

I am working on a SpringMVC 3 and Roo project. Now there is a web tier dead end. Basically it is a type conversion issue, driving me mad I try to pass the record counter when iterate a list of table

stackoverflow.com

오류 코드 전체 ('더보기' 클릭)

더보기

(오류 전체) 

심각: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [] threw exception [An exception occurred processing JSP page

...(오류가 발생한 코드 부분) ...

 

심각: Servlet.service() for servlet jsp threw exception
javax.el.PropertyNotFoundException: Property '0' not found on type java.lang.String
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:290)
at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:243)
at javax.el.BeanELResolver.property(BeanELResolver.java:377)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:97)
at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
at org.apache.el.parser.AstValue.getValue(AstValue.java:184)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:950)
at org.apache.jsp.WEB_002dINF.jsp.rad.trainingLog.trainingLogPartView_jsp._jspx_meth_c_005fforEach_005f1(trainingLogPartView_jsp.java:561)
at org.apache.jsp.WEB_002dINF.jsp.rad.trainingLog.trainingLogPartView_jsp._jspx_meth_c_005fforEach_005f0(trainingLogPartView_jsp.java:449)
at org.apache.jsp.WEB_002dINF.jsp.rad.trainingLog.trainingLogPartView_jsp._jspService(trainingLogPartView_jsp.java:233)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1201)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:986)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)