严重:Servlet [jsp]的Servlet.service()抛出异常java.lang.NumberFormatException

时间:2018-08-07 12:37:00

标签: java spring-mvc jsp

我试图从两个项目列表中显示有关JSP的候选人信息。个人信息-“ $ {candidatesPI}”和健身信息-“ $ {candidatesFI}”。

下面是显示两个列表中的信息的JSP代码。在这里,我使用两个变量var1和var2存储这两个列表中的候选ID信息,然后进行比较。将CandidateID的值存储到var1变量中时显示错误。

<c:forEach var="tempcandDet" items="${candidatesPI}" varStatus="counter">

                <c:url var="CanDet" value="/aro/searchByAadhaar">
                        <c:param name="AadhaarNo" value="${tempcandDet.aadhaarNumber}" />
                        <c:param name="candidateID" value="${tempcandDet.candidateID}" />
                    </c:url>
                <c:url var="updateLink" value="/aro/showFormForUpdate">
                        <c:param name="candidateID" value="${tempcandDet.candidateID}" />
                    </c:url>
<tr>
    <%-- <td class="DashboardTabledata" style="text-align:left">${counter.count}</td> --%>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;"><a href="${CanDet}">${tempcandDet.aadhaarNumber}</a></td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.firstName}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.middleName}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.lastName}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.postApplied}</td>
    <td class="DashboardTabledata" style="text-align:center;font-size: 14px;">${tempcandDet.eligible}</td>
    <c:forEach var="tempcandDet1" items="${candidatesFI}" varStatus="counter">
    <c:set var="var1" value="${tempcandDet1.candidateID_FI}"/>
    <c:set var="var2" value="${tempcandDet.candidateID}"/>
    <c:choose>
        <c:when test='${var1==var2}'>
    <td class="DashboardTabledata" style="text-align:center;font-size: 14px;">${tempcandDet1.runningScore}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.pullUpsScore}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.balance}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.ditch}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.medical}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.surgical}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.eye}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.ent}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet1.ceeScore}</td>
     </c:when>
     </c:choose>
     </c:forEach>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.score}</td>
    <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.result}</td>
    <%-- <td class="DashboardTabledata"><a href="${updateLink}">Update</a></td> --%>

  </tr>

</c:forEach>

我遇到错误-

Aug 07, 2018 5:01:32 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet [jsp] threw exception
java.lang.NumberFormatException: For input string: "candidateID_FI"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:144)
    at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:61)
    at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
    at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:115)
    at org.apache.jsp.WEB_002dINF.view.MainPage_005fARON_jsp._jspx_meth_c_005fset_005f9(MainPage_005fARON_jsp.java:3509)
    at org.apache.jsp.WEB_002dINF.view.MainPage_005fARON_jsp._jspx_meth_c_005fforEach_005f1(MainPage_005fARON_jsp.java:3461)
    at org.apache.jsp.WEB_002dINF.view.MainPage_005fARON_jsp._jspx_meth_c_005fforEach_005f0(MainPage_005fARON_jsp.java:3225)
    at org.apache.jsp.WEB_002dINF.view.MainPage_005fARON_jsp._jspService(MainPage_005fARON_jsp.java:357)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

Aug 07, 2018 5:01:32 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/SRS-ARONAGPUR] threw exception [An exception occurred processing [WEB-INF/view/MainPage_ARON.jsp] at line [511]

508:     <td class="DashboardTabledata" style="text-align:left;font-size: 14px;">${tempcandDet.postApplied}</td>
509:     <td class="DashboardTabledata" style="text-align:center;font-size: 14px;">${tempcandDet.eligible}</td>
510:     <c:forEach var="tempcandDet1" items="${candidatesFI}" varStatus="counter">
511:     <c:set var="var1" value="${tempcandDet1.candidateID_FI}"/>
512:     <c:set var="var2" value="${tempcandDet.candidateID}"/>
513:     <c:choose>
514:        <c:when test='${var1==var2}'>

我正在使用Spring MVC框架。这个问题特定于JSP或Spring MVC类吗?请让我知道。

1 个答案:

答案 0 :(得分:1)

您在JSP中尝试的变量是一个String,并且您试图将其转换为整数。您可能想要将其转换为整数并设置值。请查看此code base of how to convert a String to Number中的示例。您可以转换欢呼声

<fmt:parseNumber var = "parsedCandidateID" type = "number" value = "${tempcandDet1.candidateID_FI}"/>

<c:set var="var1" value="parsedCandidateID"/>

在确定了整数类型的变量之后,然后您就可以执行比较操作了。