问题遇到的现象和发生背景
layui中使用ajax获取嵌套类数据失败
问题相关代码,请勿粘贴截图
$(function () {
var doctorCode = getParam("doctorCode");
$.ajax({
url:"/SSM_hospital/doctor/queryDoctorByDoctorCode",
type:'post',
data:{"doctorCode":doctorCode},
dataType:'json',
success:function (d) {
//解析数据
$("#doctorCode").val(d.doctorCode);
$("#doctorName").val(d.doctorName);
$("#doctorSex").val(d.doctorSex);
$("#doctorBirthday").val(d.doctorBirthday);
$("#doctorPhone").val(d.doctorPhone);
$("#doctorAddress").val(d.doctorAddress);
$("#doctorPost").val(d.doctorPost);
//$("#doctorDeptId").val(d.dept.id);
//医生部门的id获取不到
$("#doctorMajor").val(d.doctorMajor);
$("#doctorProfile").val(d.doctorProfile);
layui.use('form',function () {
var form = layui.form;
form.render();
})
}
})
public class Doctor {
private String doctorCode;
private String doctorPassword;
private String doctorName;//真实姓名
private int doctorSex;
private int doctorAge;
private String doctorPost;//职位
private String doctorPhone;
private String doctorBirthday;
private String doctorProfile;//个人简介
private String doctorMajor;//主修;擅长
private String doctorAddress;
//部门
private Dept dept;
public class Dept {
private int id;
private String deptName;
private String deptAddress;