首页新闻找找看学习计划

spring 返回json的时候报错了,知道的大佬们求解答一下,谢谢!!!

0
悬赏园豆:20 [已关闭问题] 关闭于 2019-04-11 16:00

这是我写的新增数据的 方法:

@RequestMapping(value = "/add", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public Object add(HttpServletRequest request, ModelMap modelMap, @RequestBody SysRoute sysRoute) {
    sysRouteService.update(sysRoute, WebUtil.getCurrentUser());
    return setSuccessModelMap(modelMap);
}

controller类开头我也加了注解 @RestController

数据能成功插入数据了,但是在return的时候报错了;

2019-04-11 15:50:26.884 [http-bio-60000-exec-2] DEBUG [] - Using 'application/json;charset=UTF-8', given [/] and supported [application/json;charset=UTF-8, text/html;charset=UTF-8, application/json;charset=UTF-8]
2019-04-11 15:50:26.885 [http-bio-60000-exec-2] DEBUG [] - Writing [{org.springframework.validation.BindingResult.bean=org.springframework.validation.BeanPropertyBindin (truncated)...]
2019-04-11 15:50:27.735 [http-bio-60000-exec-2] DEBUG [] - Using @ExceptionHandler public void com.kysx.core.base.BaseController.exceptionHandler(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.Exception) throws java.lang.Exception
2019-04-11 15:50:27.736 [http-bio-60000-exec-2] ERROR [BaseController.java] - OH,MY GOD! SOME ERRORS OCCURED! AS FOLLOWS :
com.alibaba.fastjson.JSONException: write javaBean error, class org.springframework.beans.GenericTypeAwarePropertyDescriptor, fieldName : 0
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:326) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.ArraySerializer.write(ArraySerializer.java:63) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.ASMSerializer_4_BeanWrapperImpl.write(Unknown Source) ~[?:?]
at com.alibaba.fastjson.serializer.JSONSerializer.writeWithFieldName(JSONSerializer.java:304) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.ASMSerializer_1_BeanPropertyBindingResult.write(Unknown Source) ~[?:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:251) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:275) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.JSON.writeJSONString(JSON.java:781) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter.writeInternal(FastJsonHttpMessageConverter.java:153) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter.write(FastJsonHttpMessageConverter.java:217) ~[fastjson-1.2.23.jar:?]
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:290) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:223) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:82) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:119) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) ~[spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) ~[shiro-web-1.4.0.jar:1.4.0]
at org.apache.shiro.web.servlet.AbstractShiroFilter\(1.call(AbstractShiroFilter.java:365) ~[shiro-web-1.4.0.jar:1.4.0] at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) ~[shiro-core-1.4.0.jar:1.4.0] at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) ~[shiro-core-1.4.0.jar:1.4.0] at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387) ~[shiro-core-1.4.0.jar:1.4.0] at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) ~[shiro-web-1.4.0.jar:1.4.0] at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ~[shiro-web-1.4.0.jar:1.4.0] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:171) ~[spring-session-1.3.5.RELEASE.jar:?] at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) ~[spring-session-1.3.5.RELEASE.jar:?] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) ~[log4j-web-2.6.1.jar:2.6.1] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at org.apache.coyote.AbstractProtocol\)AbstractConnectionHandler.process(AbstractProtocol.java:603) ~[tomcat-embed-core-7.0.47.jar:7.0.47]
at org.apache.tomcat.util.net.JIoEndpoint\(SocketProcessor.run(JIoEndpoint.java:310) ~[tomcat-embed-core-7.0.47.jar:7.0.47] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor\)Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
at com.alibaba.fastjson.util.FieldInfo.get(FieldInfo.java:451) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.getPropertyValue(FieldSerializer.java:105) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:196) ~[fastjson-1.2.23.jar:?]
... 75 more
Caused by: java.lang.IllegalStateException: No write method available
at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getWriteMethodForActualAccess(GenericTypeAwarePropertyDescriptor.java:137) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
at com.alibaba.fastjson.util.FieldInfo.get(FieldInfo.java:451) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.getPropertyValue(FieldSerializer.java:105) ~[fastjson-1.2.23.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:196) ~[fastjson-1.2.23.jar:?]
... 75 more
2019-04-11 15:50:28.599 [http-bio-60000-exec-2] DEBUG [] - Resolved [com.alibaba.fastjson.JSONException: write javaBean error, class org.springframework.beans.GenericTypeAwarePropertyDescriptor, fieldName : 0]
2019-04-11 15:50:28.599 [http-bio-60000-exec-2] DEBUG [] - Completed 200 OK

自然醒--的主页 自然醒-- | 初学一级 | 园豆:121
提问于:2019-04-11 15:58
< >
分享
所有回答(1)
0

去掉, produces = "application/json;charset=UTF-8"应该就好了

不知怎么办才好 | 园豆:314 (菜鸟二级) | 2019-04-19 20:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册