javax.servlet.jsp.JspException:类型 [java.lang.String] 对选项无效
javax.servlet.jsp.JspException: Type [java.lang.String] is not valid for option items
我正在尝试从数据库中获取数据并将其显示在下拉列表中
日期
public List<String> getAllDeparment() {
String sql = "select dept_name from DEPATMENT";
return jdbcTemplate.queryForList(sql, String.class );}
服务
public List<String> getAllDept(){
return departmentDao.getAllDeparment();
}
控制器
@RequestMapping(method = RequestMethod.GET, path = "/drop")
public String drop(@ModelAttribute Depatment depatment ,Model model){
List<String> allDept = deparmentServcies.getAllDept();
model.addAttribute("deptlist",allDept);
return "drop";
}
jsp
<form:form commandName="depatment " method="post">
<form:select path="deptName">
<form:options items="${deptlist}" />
</form:select>
The problem has been solved
<form:form commandName="depatment" method="post">
<form:select path="deptName" items="${depatments}">
</form:select>
我正在尝试从数据库中获取数据并将其显示在下拉列表中
日期
public List<String> getAllDeparment() {
String sql = "select dept_name from DEPATMENT";
return jdbcTemplate.queryForList(sql, String.class );}
服务
public List<String> getAllDept(){
return departmentDao.getAllDeparment();
}
控制器
@RequestMapping(method = RequestMethod.GET, path = "/drop")
public String drop(@ModelAttribute Depatment depatment ,Model model){
List<String> allDept = deparmentServcies.getAllDept();
model.addAttribute("deptlist",allDept);
return "drop";
}
jsp
<form:form commandName="depatment " method="post">
<form:select path="deptName">
<form:options items="${deptlist}" />
</form:select>
The problem has been solved
<form:form commandName="depatment" method="post">
<form:select path="deptName" items="${depatments}">
</form:select>