将字符串解析为double获取错误java.lang.NumberFormatException:empty String

时间:2012-02-15 11:08:41

标签: java string double

我在计算字符串值时遇到此错误: Double.toString(Double.parseDouble(suggestionSortScore) - 6)

  

17:47:19,983 INFO [STDOUT] [EDS ALL LIST] NOC黑名单:Sugeng   Hindarjo

     

17:47:19,984 ERROR [[jsp]] Servlet.service()for servlet jsp thrrew   exception java.lang.NumberFormatException:empty String           at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)           在java.lang.Double.parseDouble(Double.java:510)           at org.apache.jsp.WEB_002dINF.jsp.n51Alist_jsp.getTransactionsFromIpg(n51Alist_jsp.java:380)           在org.apache.jsp.WEB_002dINF.jsp.n51Alist_jsp._jspService(n51Alist_jsp.java:581)           在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)           在javax.servlet.http.HttpServlet.service(HttpServlet.java:803)           在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)           在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)           在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)           在javax.servlet.http.HttpServlet.service(HttpServlet.java:803)           在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)           在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)           at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)           在org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)           在org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)           在org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)           在nsia.owasp.util.Controller.doPost(Controller.java:166)           在javax.servlet.http.HttpServlet.service(HttpServlet.java:710)           在javax.servlet.http.HttpServlet.service(HttpServlet.java:803)           在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)           在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)           在org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)           在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)           在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)           在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)           在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)           在org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)           在org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)           在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)           在org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)           在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)           在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)           在org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:437)           at org.apache.coyote.ajp.AjpProtocol $ AjpConnectionHandler.process(AjpProtocol.java:366)           在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:446)           at java.lang.Thread.run(Thread.java:662)17:47:19,984 INFO [STDOUT] Exception => org.apache.jasper.JasperException:一个例外   发生在第370行处理JSP页面/WEB-INF/jsp/n51Alist.jsp

     

367:if(cekBlackListByNoc == true){

     

368:System.out.println(" [EDS ALL LIST] NOC BLACK   列表:" + nameOnCardDecrypt);

     

369:数据[0] ="黄色&#34 ;;

     

370:数据[17] =   Double.toString(Double.parseDouble(suggestionSortScore) - 6);

     

371:if(Double.parseDouble(data [17])< 3.0){

     

372:数据[17] =" 3.1&#34 ;;

     

373:}

为什么stacktrace说emptystring?搭建的商品充满了价值" 5.0"。

2 个答案:

答案 0 :(得分:1)

Double.toString(Double.parseDouble(suggestionSortScore) - 6) - 仅当字符串suggestionSortScore不包含可解析的double时才会通过例外

答案 1 :(得分:0)

该异常由Double.parseDouble(suggestionSortScore)发起,并表示建议分数为空,我会再次检查。

无论如何,您可以查看以下文档:parseDouble