我试图在jsp页面中打印列表,但我收到错误java.lang.NumberFormatException.forInputString
我看到了类似于我的问题(number Exception) 对他/她来说,接受的答案是用一个“foreach”来重复列表,但是我做了它并且它仍然给了我这个错误。
有人可以帮助我吗?
这是jsp
<tr class="odd">
<th style="width: 25px;" class="border" align="center">#</th>
<th style="width: 200px;" class="border">Process</th>
<th style="width: 328px;" class="border">Time Schedule</th>
<th style="width: 100px;" class="border">Next time running</th>
<th style="width: 50px;" class="border">Server</th>
<th style="width: 50px;" class="border">On || Off</th>
<th style="width: 50px;" class="border">Emails</th>
<th style="width: 50px;" class="border">Description</th>
</tr>
</thead>
<tbody>
<c:forEach items="${JobList}" var="job" varStatus="index">
<td align="center">${index.count}</td>
<td align="center">${job.process}</td>
<td align="center">${job.schedTime}</td>
<td align="center">${job.nextTimeRun}</td>
<td align="center">${job.server}</td>
<td align="center">${job.isActive}</td>
<td align="center">${job.email}</td>
<td align="center">${job.description}</td>
</tr>
</c:forEach>
<tr><td colspan="6"> </td></tr>
</tbody>
这里是数据库
private String process;
private String schedTime;
private String nextTimeRun;
private String runServer;
private String mailOrder;
private String lookCode;
private String lookName;
private String description;
private String isActive;
/* getter and setter methods */
这是控制器中设置JobList
的方法 public ModelAndView showAppJobsList(final HttpServletRequest request, final HttpServletResponse response) throws BillerException
{
final ModelAndView modelAndView = new ModelAndView("admin/showAppJobs");
List<LookUpJobs> lookUpJobsList =lookupSvc.getJobsList();
modelAndView.addObject("JobList", lookUpJobsList);
return modelAndView;
}
,错误是这样的:
java.lang.NumberFormatException: For input string: "process"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:153)
at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:45)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
at org.apache.jsp.WEB_002dINF.configureJSP.admin.showAppJobs_jsp._jspx_meth_c_005fforEach_005f1(showAppJobs_jsp.java:789)
at org.apache.jsp.WEB_002dINF.configureJSP.admin.showAppJobs_jsp._jspService(showAppJobs_jsp.java:312)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:142)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:243)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1141)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:878)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:430)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:662)
答案 0 :(得分:1)
我找到了答案,问题不在jsp中,问题出在dao中,不知怎的,当它映射时,hibernate检索了列表,但是无法映射值,所以我不得不添加一个别名来所有列,然后为查询中的每一列添加Scalar,就像这样。
public List<LookUpJobs> getJobsList(){
return (List<LookUpJobs>)
getSession().createSQLQuery("select "
+ "j.type type,"
+ " j.description process,"
+ " j.value schedTime,"
+ " from tableName j inner join tableName m on j.type = m.value")
.addScalar("type",Hibernate.STRING)
.addScalar("process",Hibernate.STRING)
.addScalar("schedTime",Hibernate.STRING)
.setResultTransformer(Transformers.aliasToBean(LookUpJobs.class))
.list();
}