现在我被一个错误卡住了,它在 Eclipse 浏览器中显示以下错误。错误看起来像:
13:53:12,294 INFO [STDOUT] 30
13:53:12,294 ERROR [[Expthsmon]] Servlet.service() for servlet Expthsmon threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Expthsmon.doGet(Expthsmon.java:44)
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.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:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
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:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
我相信这部分代码
int amountofnoon=0;
int amountofafternoon=0;
int noofnoon=0;
int noofafternoon=0;
String amountnoon=null;
String amountafternoon=null;
amountnoon=request.getParameter("amountnoon");
amountafternoon=request.getParameter("amountafternoon");
//if((amountnoon !=null )&&(amountafternoon !=null))
amountofnoon=Integer.parseInt(amountnoon);
System.out.println(""+amountofnoon);
amountofafternoon=Integer.parseInt(amountafternoon);
System.out.println(""+amountofafternoon);
正在制造问题,其中amountofnoon 和amountofafternoon 应该是整数值。我该怎么办?
我还添加了从中获取值的代码的 jsp 部分:
<form name="expenditurefthsmon" action="Expthsmon">
<div align="center">Enter The Amount of Days Expenditure</div>
<div align="center"><input type="text" name="amountnoon"></input></div>
<div align="center">Enter The Amount of Nights Expenditure</div>
<div align="center"><input type="text" name=amountafternoon"></input></div>
<div align="center"><input type="submit" value="Calculate"></input></div>"
</form>