Spring - java.lang.NumberFormatException: For input string -
i'm trying list of users , associated objects using dto. far there error.
model
public class userentity @onetomany(cascade=cascadetype.all, fetch=fetchtype.lazy, mappedby="setter") private set<module> smodule = new hashset<module>(); @onetomany(cascade=cascadetype.all, fetch=fetchtype.lazy, mappedby="checker") private set<module> cmodule = new hashset<module>(); //getters , setters
dto
public class userentitydto { private list<module> smodule = new arraylist<module>(); private list<module> cmodule = new arraylist<module>();
controller
@requestmapping(value = "/main/user/testing", method = requestmethod.get) public string getrecords(model model) { list<userentity> users = userservice.getuserentity(); list<userentitydto> usersdto = new arraylist<userentitydto>(); (userentity user: users) { userentitydto dto = new userentitydto(); dto.setuserid(user.getuserid()); dto.setname(user.getname()); dto.setsmodule(moduleservice.getsettermodules(user.getuserid())); dto.setcmodule(moduleservice.getcheckermodules(user.getuserid())); usersdto.add(dto); } model.addattribute("users", usersdto); return "/main/user/testing"; }
jsp page
<table> <tr> <th>user id</th> <th>user name</th> <th>module</th> </tr> <c:foreach items="${users}" var="setter" > <c:foreach items="${users.smodule}" var="module" > <tr> <td><c:out value="${setter.userid}" escapexml="true" /></td> <td><c:out value="${setter.name}" escapexml="true" /></td> <td><c:out value="${module.modulecode}" escapexml="true" /></td> <td><c:out value="${module.modulename}" escapexml="true" /></td> <td><c:out value="${module.modulestatus}" escapexml="true" /></td> </tr> </c:foreach> </c:foreach> </table>
the stacktrace
java.lang.numberformatexception: input string: "smodule" java.lang.numberformatexception.forinputstring(numberformatexception.java:65) java.lang.integer.parseint(integer.java:492) java.lang.integer.parseint(integer.java:527) javax.el.listelresolver.coerce(listelresolver.java:173) javax.el.listelresolver.getvalue(listelresolver.java:52) org.apache.jasper.el.jasperelresolver.getvalue(jasperelresolver.java:104) org.apache.el.parser.astvalue.getvalue(astvalue.java:183) org.apache.el.valueexpressionimpl.getvalue(valueexpressionimpl.java:185) org.apache.jasper.el.jspvalueexpression.getvalue(jspvalueexpression.java:106) org.apache.jsp.web_002dinf.views.main.user.testing_jsp._jspx_meth_c_005fforeach_005f1(testing_jsp.java:204) org.apache.jsp.web_002dinf.views.main.user.testing_jsp._jspx_meth_c_005fforeach_005f0(testing_jsp.java:172) org.apache.jsp.web_002dinf.views.main.user.testing_jsp._jspservice(testing_jsp.java:111) org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:70) javax.servlet.http.httpservlet.service(httpservlet.java:728) org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:432) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:390) org.apache.jasper.servlet.jspservlet.service(jspservlet.java:334) javax.servlet.http.httpservlet.service(httpservlet.java:728) org.springframework.web.servlet.view.internalresourceview.rendermergedoutputmodel(internalresourceview.java:238) org.springframework.web.servlet.view.abstractview.render(abstractview.java:264) org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1208) org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:992) org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:939) org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:915) org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:811) javax.servlet.http.httpservlet.service(httpservlet.java:621) org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:796) javax.servlet.http.httpservlet.service(httpservlet.java:728) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330) org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118) org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:54) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.www.basicauthenticationfilter.dofilter(basicauthenticationfilter.java:150) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:183) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:105) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.access.channel.channelprocessingfilter.dofilter(channelprocessingfilter.java:144) org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192) org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160) org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:346) org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:259)
it taking exception @ child objects want retrieve. how can make sure field want can accepted.
you're accessing modules in jsp in wrong way.
this:
<c:foreach items="${users}" var="setter" > <c:foreach items="${users.smodule}" var="module" >
tries access smodule
member of users
, , since users
list tries convert smodule
integer , use index.
it should be:
<c:foreach items="${users}" var="user" > <c:foreach items="${user.smodule}" var="module" >
Comments
Post a Comment