student_form.jsp
<form:form action="studentProcess" modelAttribute="student">
Ime : <form:input path="username"/>
Prezime : <form:input path="password"/>
<br>
<form:select path="mapaBroj">
<form:options items="${student.mapaBroj}"/>
</form:select>
<br>
Muski : <form:radiobutton path="pol" value="Muski"/>
Zenski : <form:radiobutton path="pol" value="Zenski"/>
<input type="submit" value="OK">
</form:form>
学生控制器
@Controller
@RequestMapping("/student")
public class StudentKontroler {
@RequestMapping("/studentForma")
public String studentForma(Model model) {
Student student = new Student();
model.addAttribute("student", student);
return "student_form";
}
@RequestMapping("/studentProcess")
public String studentProcess(@ModelAttribute("student") Student student) {
return "student_ispis";
}
}
和student_ispis.jsp
Ime studenta : ${student.username} <br>
Sifra studenta : ${student.password} <br>
Vrijednost : ${student.mapaBroj} <br>
Pol : ${student.pol} <br>
学生模型类:
public class Student {
private String username;
private String password;
private String broj;
private LinkedHashMap<String, String> mapaBroj;
private String pol;
...
}
它看起来像这样:
它看起来根本不像选择选项。当我按下“提交”按钮时,它会引发以下消息:“由于某些原因(可能是客户端语法错误,无效的请求消息框架或欺骗性的请求路由),服务器无法或不会处理该请求。 “