struts2 ajax json异常
在我的 struts2 应用程序中进行 AJAX 调用时,出现以下错误:
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.write(JSONWriter.java:99)
org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112)
org.apache.struts2.json.JSONResult.execute(JSONResult.java:198)
com...hony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
进行 ajax 调用时执行正确的操作/方法。
我使 Action 类中引用的所有对象都实现了可序列化。
我可以做什么来解决这个问题?我一直在互联网上搜索..但没有线索..
I am getting the below error when making an AJAX call in my struts2 application:
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.write(JSONWriter.java:99)
org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112)
org.apache.struts2.json.JSONResult.execute(JSONResult.java:198)
com...hony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
The correct Action/method are executed when the ajax call is made.
I made all objects referenced in the Action class implement Serializable.
What can i do to fix this problem? I have been searching on the internet .. but no clues..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发现问题..我的类中有 BidDecimal 对象,并且这种类型不支持 JSON 序列化。我将它转换为字符串和双精度,它现在可以工作了。
The found the problem .. I had BidDecimal objects in my class and JSON serialization is not supported for this type. I converted it to String and double and it iw working now.
通过向 struts.xml 添加“includeProperties”参数并限制作为 AJAX 调用响应传递的变量解决了该错误。
“returnResult”是包含作为 AJAX 调用响应传递的数据的变量。
solved the error by adding "includeProperties" param to the struts.xml and limiting the variables passed as the response for the AJAX call.
"returnResult" is the variable containing the data which was passed as the response for the AJAX call.