-1
當我啓動我的jsp時,我使用javascript函數在會話中爲用戶收費。 javascript函數使用JSON和struts2操作。這是代碼:使用Struts2的JSON錯誤
JSP:
<body>
<script>usarAJAXCargarCookie();</script>
...
</body>
的Javascript:
function usarAJAXCargarCookie() {
var userCookie = getCookie('userCookieSL');
$.getJSON('ajaxCookie', {
userCookie: userCookie
}, function (jsonResponse) {
});
}
struts.xml的
<action name="ajaxCookie" class="Acciones.HomeFavoritos" method="ajaxCookie">
<result type="json">
<param name="excludeNullProperties">true</param>
<param name="noCache">true</param>
</result>
</action>
HomeFavoritos.java
@SkipValidation
public String ajaxCookie() throws Exception{
if(sesion==null){
sesion=ActionContext.getContext().getSession();
}
if(sesion.get("usuarioLogueado") == null || sesion.get("usuarioLogueado").equals("")){
cargarUsuarioNoLogueado(sesion, userCookie);
} else {
cargarUsuarioLogueado(sesion);
}
return SUCCESS;
}
我收到此錯誤:
Grave: Exception occurred during processing request: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:246)
at org.apache.struts2.json.JSONWriter.processCustom(JSONWriter.java:178)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:168)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)
at org.apache.struts2.json.JSONWriter.write(JSONWriter.java:102)
at org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:116)
at org.apache.struts2.json.JSONResult.createJSONString(JSONResult.java:197)
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:171)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
這是目前還不清楚什麼是你想返回的JSON響應。 –