我有一个 Java 对象,我使用 ModelandView 的一部分,如下所示,
弹簧控制器:-
@RequestMapping(value = "/student", method = RequestMethod.GET)
public ModelAndView student() {
return new ModelAndView("student", "command", new Student());
}
Java对象:-
import java.util.List;
public class Student {
private Integer age;
private String fname;
private String mname;
private String lname;
private String dob;
private List gender;
private String birthplace;
private String nationality;
private String mothertongue;
private String religion;
private Integer id;
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getMname() {
return mname;
}
public void setMname(String mname) {
this.mname = mname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
public List getGender() {
return gender;
}
public void setGender(List gender) {
this.gender = gender;
}
public String getBirthplace() {
return birthplace;
}
public void setBirthplace(String birthplace) {
this.birthplace = birthplace;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getMothertongue() {
return mothertongue;
}
public void setMothertongue(String mothertongue) {
this.mothertongue = mothertongue;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
JSP 文件
<h2>Student Information</h2>
<form:form method="POST" action="/SpringMVC/addStudent">
<table>
<tr>
<td><form:label path="name">Name</form:label></td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td><form:label path="age">Age</form:label></td>
<td><form:input path="age" /></td>
</tr>
<tr>
<td><form:label path="id">id</form:label></td>
<td><form:input path="id" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
</form:form>
问题:-
我需要传递一份性别清单,即;MALE 和 FEMALE 到 JSP 文件中...我可以将它作为数组添加到我的 Java 对象中,但是如何在我的 JSP 文件中引用...