javaweb报错:java.lang.NumberFormatException: null

报错环境:

JSP向Severlet页面传值,当Serverlet页执行以下语句时,后台日志报错

   int softType = Integer.parseInt(request.getParameter("softType"));

 

javaweb报错:java.lang.NumberFormatException: null
2014-3-27 14:36:57 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [softClServlet] in context with path [/dms] threw exception
java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:417)
    at java.lang.Integer.parseInt(Integer.java:499)
    at com.trs.dms.controller.softClServlet.doPost(softClServlet.java:83)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
报错日志

问题分析:

该语句把一个NULL的值转化为INT类型了,即request.getParameter("softType")值为空,在转化前判断是否为NULL 若为NULL 跳过转化给个message

javaweb报错:java.lang.NumberFormatException: null,布布扣,bubuko.com

javaweb报错:java.lang.NumberFormatException: null

上一篇:python import 的区别


下一篇:JavaScript将输入的数字金额转换成对应的中文大写金额