1.action类引入struts2的"json-default"拦截器栈
@ParentPackage("json-default")
//示例
@ParentPackage(WapBaseAction.WAP_PACKAGE) //WAP_PACKAGE继承了json-default
@Namespace("/")
public class ModifyResumeAction extends WapBaseAction {...
2.@Action的result类型为json同时可以设置params
@Action(value = "creatResume", results = {@Result(name = JSON,type=JSON, params={ROOT,RESULT})})
3.jquery序列化form表单使用ajax提交
$.ajax({
url: "<eiss:site site="WAP_CENTER"/>/creatResume",
data: $("form").serialize(), //序列化form表单
type: "POST",
dataType: "json",
success: function(result){ //result为返回json数据
$.alert(result.message,function() {
window.location.href = "<eiss:site site="WAP_CENTER"/>/myResumes";
});
}
});
});