2015-01-06 78 views
1

我想打印在JSP頁面的列表,但我得到的錯誤java.lang.NumberFormatException.forInputString異常:NumberFormatException的:對於JSP列表頁輸入字符串

不過,我沒有使用任何數字或轉化什麼都是數字,我真的不知道我做錯了什麼,請幫助我。

我看到一個類似於我的問題(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">&nbsp;</td></tr> 
    </tbody> 

這裏的公司Databeans

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 */ 

這是在設置作業表

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

您的意思是使用'runServer'而不是'server'嗎? –

+0

問題不在於服務器,是在所有的列中,它標誌着同樣的錯誤。 – jose

+0

具有相同的值嗎?看看這個錯誤 - 它試圖將一個字符串'server'解析爲一個整數。 –

回答

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(); 
} 
相關問題