- 浏览: 166635 次
- 性别:
- 来自: 厦门
文章分类
最新评论
-
liuborama:
System.out.println(Math ...
Math.round()和Math.floor() -
KevinGarnett:
正遇到这问题,楼主解释的非常好 谢谢
当return遇到finally
报错内容:
原因:JSON不允许里面的值有无穷值,例如
如果d.isInfinite()为true,再把d的值放到JSON中,则会报如上异常,
解决办法:
判断一下传入JSON中的值,如果isInfinite()==true则返回null,加入判断:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is net.sf.json.JSONException: JSON does not allow non-finite numbers at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) at javax.servlet.http.HttpServlet.service(HttpServlet.java:643) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:49) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) 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:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) 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:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) Caused by: net.sf.json.JSONException: JSON does not allow non-finite numbers at net.sf.json.util.JSONUtils.testValidity(JSONUtils.java:597) at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:269) at net.sf.json.JSONObject._processValue(JSONObject.java:2655) at net.sf.json.JSONObject.processValue(JSONObject.java:2721) at net.sf.json.JSONObject.setInternal(JSONObject.java:2736) at net.sf.json.JSONObject.setValue(JSONObject.java:1424) at net.sf.json.JSONObject.defaultBeanProcessing(JSONObject.java:765) at net.sf.json.JSONObject._fromBean(JSONObject.java:699) at net.sf.json.JSONObject.fromObject(JSONObject.java:172) at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274) at net.sf.json.JSONArray._processValue(JSONArray.java:2513) at net.sf.json.JSONArray.processValue(JSONArray.java:2538) at net.sf.json.JSONArray.addValue(JSONArray.java:2525) at net.sf.json.JSONArray._fromCollection(JSONArray.java:1056) at net.sf.json.JSONArray.fromObject(JSONArray.java:123) at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:240) at net.sf.json.JSONObject._processValue(JSONObject.java:2655) at net.sf.json.JSONObject.processValue(JSONObject.java:2721) at net.sf.json.JSONObject.setInternal(JSONObject.java:2736) at net.sf.json.JSONObject.setValue(JSONObject.java:1424) at net.sf.json.JSONObject.defaultBeanProcessing(JSONObject.java:765) at net.sf.json.JSONObject._fromBean(JSONObject.java:699) at net.sf.json.JSONObject.fromObject(JSONObject.java:172) at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:274) at net.sf.json.JSONArray._processValue(JSONArray.java:2513) at net.sf.json.JSONArray.processValue(JSONArray.java:2538) at net.sf.json.JSONArray.addValue(JSONArray.java:2525) at net.sf.json.JSONArray._fromCollection(JSONArray.java:1056) at net.sf.json.JSONArray.fromObject(JSONArray.java:123) at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:240) at net.sf.json.JSONObject._processValue(JSONObject.java:2655) at net.sf.json.JSONObject.processValue(JSONObject.java:2721) at net.sf.json.JSONObject.element(JSONObject.java:1786) at net.sf.json.JSONObject.element(JSONObject.java:1764) at net.sf.json.JSONObject.put(JSONObject.java:2380) at com.ways.gtmc.app.webapp.controller.CitySaleAnalyController.getSales(CitySaleAnalyController.java:179) at sun.reflect.GeneratedMethodAccessor171.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) ... 55 more
原因:JSON不允许里面的值有无穷值,例如
Integer a = 1; Integer b = 0; Double d =(double)a/(double)b; System.out.println(d.isInfinite());//输出true
如果d.isInfinite()为true,再把d的值放到JSON中,则会报如上异常,
解决办法:
判断一下传入JSON中的值,如果isInfinite()==true则返回null,加入判断:
if(d.isInfinite()){ return null; }
发表评论
-
java 客户端用http方式上传图片到服务器
2015-03-31 18:10 0//服务端 @RequestMapping("/u ... -
excel导入
2014-11-25 09:42 0exceldaoru -
basis应用
2014-11-05 09:45 0应用 -
把下划线式变量转换成驼峰式变量
2014-08-11 10:03 4918package com.ways.app.dpca.uti ... -
A fatal error has been detected by the Java Runtime Enviro
2014-08-07 16:37 1455Myeclipse中启动一个项目(项目过大、架构不合理,加载 ... -
以读取XML方式的大批量导入Excel
2014-08-07 14:58 1774以读取XML方式的导入Excel -
POI单元格数据类型匹配
2014-03-27 20:09 1233/** * 设置单元格值 * @param wb ...
相关推荐
检查你代码的 JSONEObject.fromObject(result) 代码位置,参数result不符合Json的定义格式,所以无法转换成Json格式,导致报出上述错误。 解决办法: 好好检查下你的result参数,按照Json规范定义。 如果一定要输出...
从服务端收到的json中有中文 然后JsonData jd = JsonMapper.ToObject(strJson); json中如有中文 会出现\uXXXX\uXXXX等 我改了下 上传了能解决此问题的litjson版本
org.json.JSONObject的6个jar包 commons-beanutils;commons-collections;commons-lang;commons-logging;ezmorph;json-lib
用Java编程语言进行编码和解码JSON对象所需要的jar包。。
JSON与JAVA数据的相互转换 import net.sf.json.JSONArray; import net.sf.json.JSONException; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; 非常方便的工具类!
3.6.8+JSON+MySQL+Annotation,并且对Dao和Service进行了封装,内含.jar包,并且解决了一对多双向关联的could not initialize proxy - no Session错误,同时解决了……invoked on net.sf.json.JSONException: There ...
org.json.JSONObject引用依赖包
litjson-develop0.36.0 C#使用LitJson解析Json数据 接受MQ服务器返回的值
解决JsonException: Max allowed object depth reached while trying to export from type UnityEngine.Vector3
JSON NET For Unity 2.0.1
此文档包含类库和文档。 类文件如下: JSON:解析json字符串 JSONObject:json对象 JSONArray:json数组 JSONException:json异常 详见javadoc
目录解析器 解析目录并生成其结构树。 用其他语言阅读:英语| 1.什么是目录解析器 1.1简介 Dir解析器是基于Node.js的功能强大的文件夹分析工具,可以在命令行或JavaScript代码中使用。 可以设置许多实用参数,以...
org.json全部源代码 1、CDL.java 2、Cookie.java 3、CookieList.java 4、HTTP.java 5、HTTPTokener.java 6、JSONArray.java 7、JSONException.java 8、JSONML.java 9、JSONObject.java 10、JSONString.java 11、...
如果需要解析的数据间存在级联关系,而互相嵌套引用,在hibernate中极容易嵌套而抛出net.sf.json.JSONException: There is a cycle in the hierarchy异常。
// Second argument is whether or not to print errors第二个是使用字符串: String json = "...";JSONObject obj;try (JSONInputStream in = new JSONInputStream(json)) {obj = in.readObject();} catch ...
JsonUtil
在异常中包装JSON编码/解码错误 围绕json_encode()和json_decode()的简单包装,用于捕获任何错误而无需执行json_last_error() 。 在PHP 7.3中,这些函数将。 use Eastwest \ Json \ Json ; use Eastwest \ Json \ ...
解析json的工具类,包括JSONObject、JSONArray、JSONException、JSONString等
本文实例为大家分享了...import org.json.JSONException; import org.json.JSONObject; /** * * 科室 * Created by LICHENGLONG on 2017-10-02. */ public class BasSection { public Integer id;//科室id pub
主要介绍了springmvc json类型转换错误解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下