http://blog.youkuaiyun.com/zhanghong0603/article/details/51851219
1、struts.xml配置
<!-- 查询人员信息 -->
<action name="validateDealper" class="sealBusinessAction" method="validateDealper">
<result type="json">
<param name="includeProperties">dealperson\.id,dealperson\.mobile,dealperson\.telephone,dealperson\.address</param>
</result>
</action>
2、action
public String validateDealper() {
String dealper = getRequest().getParameter("dealper");
String dealpercode = getRequest().getParameter("dealpercode");
this.dealperson = this.sealbusinessService.Getdealperson(dealper,
dealpercode);
return SUCCESS;
}
private String jsonResultMsg = null;
public String getJsonResultMsg() {
return jsonResultMsg;
}
public void setJsonResultMsg(String jsonResultMsg) {
this.jsonResultMsg = jsonResultMsg;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
3、js
var dealperson = msg.dealperson;获得后台查询的对象。
$.ajax( {
type : "post",
url : "validateDealper.action",
dataType : "json",
data : {"dealper":getper,"dealpercode":code},
async : false,
cache : false,
success : function(msg) {
var dealperson = msg.dealperson;
if (dealperson != null) {
var id = dealperson.id;
var mobile = dealperson.mobile;
var telephone = dealperson.telephone;
var address = dealperson.address;
$("#dealpersonid").val(id);
$("#mobile").val(mobile);
$("#telephone").val(telephone);
$("#address").val(address);
}
}
});