struts2 <s:select>标签
Servlet.service()forservletjspthrewexceptiontag'select',field'list',name'user.departm...
Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'user.department.departmentcode': The requested list key '#request.list_department' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
biz层
public List findDepartment() {
String hql = "from Department ";
List list = this.getDao().find(hql);
return list;
}
action 层
public String findDepartment(){
List list = this.biz.findDepartment();
ServletActionContext.getRequest().setAttribute("list_department", list);
return "";
}
private Department department;
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
jsp
<s:action name="user!findDepartment"></s:action>
<s:select theme="simple" name="user.department.departmentcode" headerKey="-1" headerValue="全部"
list="#request.list_department" listKey="department.departmentcode" listValue="department.departmentname">
</s:select> 展开
tag 'select', field 'list', name 'user.department.departmentcode': The requested list key '#request.list_department' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
biz层
public List findDepartment() {
String hql = "from Department ";
List list = this.getDao().find(hql);
return list;
}
action 层
public String findDepartment(){
List list = this.biz.findDepartment();
ServletActionContext.getRequest().setAttribute("list_department", list);
return "";
}
private Department department;
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
jsp
<s:action name="user!findDepartment"></s:action>
<s:select theme="simple" name="user.department.departmentcode" headerKey="-1" headerValue="全部"
list="#request.list_department" listKey="department.departmentcode" listValue="department.departmentname">
</s:select> 展开
4个回答
展开全部
jsp页面报错,#request.list_department不能作为一个集合访问。问题出在这一句吧:ServletActionContext.getRequest().setAttribute("list_department", list);这样设置,在页面取到的是一个字符串,可以先在后台转换为json,在jsp页面获取再反转一次即可。不过,简单点的做法是在action里设置一个类似集合的属性,把值赋给这个属性,然后直接调用这个属性即可。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
TableDI
2024-07-18 广告
2024-07-18 广告
VLOOKUP 是 Excel 中一个非常实用的函数,它允许用户在一个区域或表格的首列中查找特定值,并返回同一行中指定列中的值。当进行跨表匹配时,你可以使用 VLOOKUP 函数将两个不同表格中的数据关联起来。通过指定查找值、表格数组、列号...
点击进入详情页
本回答由TableDI提供
展开全部
嗯 你可以试试listKey="departmentcode" listValue="departmentname" 前面不用department的 你要那个干什么呢啊
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看看action list 有没有东西 ,,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
什么东西
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询