[AppleScript] 纯文本查看 复制代码
var url = "${pageContext.request.contextPath}/userAction_calMethod.action";
$.post(url,{'param':value},function(data){
if(data.resultCode == "200"){
$.messager.alert('提示信息','操作成功!','info');
}else{
$.messager.alert('提示信息','操作失败!','warning');
}
});
[XML] 纯文本查看 复制代码
<!--action所在的package继承json-default或者其父继承json-default -->
<package name="basicstruts2" extends="json-default">
<action name="userAction_*" class="userAction" method="{1}">
<!--type为json-->
<result name="resultStatus" type="json">
<!--
指定将被Struts2序列化的属性,也就是UserAction方法中的resultMsg。
注意:
如果不写root param则返回的并不是我们想要的数据
-->
<param name="root">resultMsg</param>
</result>
</action>[/size][size=3][size=3]
<package >[/size]
[Java] 纯文本查看 复制代码
//创建状态类,用于向页面返回结果
public class ResultMessage {
private String resultCode;
private String message;
private Object[] messages;
public ResultMessage() {
}
public ResultMessage(String resultCode, String message) {
this.resultCode = resultCode;
this.message = message;
}
public String getResultCode() {
return resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object[] getMessages() {
return messages;
}
public void setMessages(Object[] messages) {
this.messages = messages;
}
}