什么可以写入数据[i]部分在jquery获取课程名称,我写了数据[i] .course.coursename但它没有工作
以下是我的模特,教育和课程;
@Entity
@Table(name = "Education", schema = "xxx")
public class Education implements java.io.Serializable {
@JsonBackReference
private Course course;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "COURSEID", nullable = false)
public Course getCourse() {
return this.course;
}
public void setCourse (Course course) {
this.course = course;
}
和
@Entity
@Table(name = "COURSE", schema = "xxx")
public class Course implements java.io.Serializable {
@JsonManagedReference
private Set<Education> educations = new HashSet<Education>(0);
@OneToMany(fetch = FetchType.LAZY, mappedBy = "course")
public Set<Education> getEducations() {
return this.educations;
}
public void setEducations(Set<Education> educations) {
this.educations = educations;
}
和jquery部分用于级联下拉
$('#departmentid').change(
function() {
$.getJSON('loadCourse',{
departmentid : $(this).val()
}, function(data) {
var html = '<option value="">----Select Course----</option>';
var len = data.length;
for ( var i = 0; i < len; i++) {
html += '<option value="' + data[i].educationid + '">' + data[i].course.coursename + ' ' + data[i].course.prefix + '</option>';
}
html += '</option>';
$('#educationid').html(html);
}).error(function(jqXHR, textStatus, errorThrown){ /* assign handler */
/* alert(jqXHR.responseText) */
alert(errorThrown);
});
});