返回信息流使用appfuse1.7
任务是做用户注册jsp页面。
数据库中的用户信息表中有“所在部门ID”字段。在数据库中另有一张部门信息表,存放所在部门ID和与之对应的部门名称。
想要在注册页面中获取数据库中部门信息给html:option标签,实现通过下拉框显示部门名称,供用户选择部门名称,然后注册确认时,提交的是对应部门ID。
在jsp中:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<bean:define id="deptCollection" name="departmentForm" property="dept" />
<html:select property="dept_id">
<html:options collection="deptCollection" property="id" labelProperty="deptname" />
</html:select>
在DepartmentForm类中,定义了list集合。
protected List dept;
public List getDept() {
DepartmentAction depa=new DepartmentAction();
DepartmentManager depm=(DepartmentManager)depa.getBean("departmentManager");
Department depart=new Department();
List dept =(List)depm.getDepartments(depart);
return dept;
}
public void setDept(List dept) {
this.dept = dept;
}
运行报错:javax.servlet.jsp.JspException: Cannot find bean departmentForm in any scope
department换成Department也不行。
麻烦各位给看看,谢谢了。
这是一条镜像帖。来源:北邮人论坛 / java / #13823同步于 2010/3/31
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
请教<html:select>标签问题
paradisefeng
2010/3/31镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
解决问题
原因是struts的action-mapping是由模板生成,默认写成了
/**
*@struts.action name="departmentForm" path="/departments" scope="request"
*/
把request改为session即可。
结贴