报错信息
org.apache.struts2.json.JSONException: Input string is not well formed JSON (invalid char )
org.apache.struts2.json.JSONReader.buildInvalidInputException(JSONReader.java:155)
org.apache.struts2.json.JSONReader.read(JSONReader.java:119)
org.apache.struts2.json.JSONReader.read(JSONReader.java:74)
org.apache.struts2.json.JSONUtil.deserialize(JSONUtil.java:162)
org.apache.struts2.json.JSONUtil.deserialize(JSONUtil.java:188)
org.apache.struts2.json.JSONInterceptor.intercept(JSONInterceptor.java:101)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
前台js
var jsontext={'user':{'name':'wang'}};
$.ajax( {
type : "POST",
url:'../../security/user1/test',
data:jsontext,
contentType:'application/json',
complete : function() {
},
action
public class UserAction1 {
private User user;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String test(){
return "grid";
}
}
struts.xml
<package name="security.user1" extends="json-default"
namespace="/security/user1">
<action name="*" class="userAction1" method="{1}">
<interceptor-ref name="json">
<param name="excludeProperties">
user.name
</param>
</interceptor-ref>
<result name="grid" type="json">
<param name="includeProperties">
grid.*
</param>
</result>
</action>
</package>