小编典典

异常:NumberFormatException:对于JSP列表页面中的输入字符串

java

我正在尝试在jsp页面中打印列表,但出现错误 java.lang.NumberFormatException.forInputString

但是,我没有使用任何数字或将任何东西转换为数字,而且我真的不知道我在做什么错,请帮助我。

我看到了一个与我的问题类似的问题,他(她)接受的答案是使用“
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">&nbsp;</td></tr>
  </tbody>

这是数据bean

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)

阅读 259

收藏
2020-09-28

共1个答案

小编典典

我找到了答案,问题不在jsp中,问题在dao中,以某种方式在映射时,hibernate检索了列表,但无法映射值,所以我不得不向所有列添加别名然后为查询中的每一列添加标量,如下所示。

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();
}
2020-09-28