<s:select>从数据库提取数据 100

错误:严重:Servlet.service()forservlet[jsp]incontextwithpath[/HibernateDemo]threwexception... 错误:严重: Servlet.service() for servlet [jsp] in context with path [/HibernateDemo] threw exception [tag 'select', field 'list', name 'student': The requested list key 'list' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]] with root cause
tag 'select', field 'list', name 'student': The requested list key 'list' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]

jsp页面
<body>
<h1>请输入需要添加的用户信息</h1>
<s:form action="student_addStudent">
<s:textfield label="学生姓名" name="student.sname" />
<s:debug></s:debug>
<s:select label="班级" name="student" list="list" ></s:select>
<s:submit></s:submit>
</s:form>
<a href="student_getAll">显示</a>
</body>

struts.xml:
<constant name="struts.devMode" value="true"></constant>
<package name="bs" extends="struts-default" strict-method-invocation="false">
<action name="student_*" class="com.sc.oa.action.StudentAction" method="{1}">
<result>/success.jsp</result>
<result name="addStudent" type="redirectAction">student_getAll</result>
</action>
</package>

action:
private ClassRoom classRoom;
private Student student;
private List<Student> list = new ArrayList<Student>();
StudentBiz sb = new StudentBizImp();

public Student getStudent() {
return student;
}

public void setStudent(Student student) {
this.student = student;
}

public ClassRoom getClassRoom() {
return classRoom;
}

public void setClassRoom(ClassRoom classRoom) {
this.classRoom = classRoom;
}

public List<Student> getList() {
return list;
}
public void setList(List<Student> list) {
this.list = list;
}

public String getAll(){
// StudentBiz sb = new StudentBizImp();
// sb.getAll();
list = sb.getAll();
return SUCCESS;
}
public String addStudent(){

sb.addStudent(student);

return "addStudent";
}
展开
 我来答
沙安福gP
2017-09-08 · 超过42用户采纳过TA的回答
知道小有建树答主
回答量:56
采纳率:0%
帮助的人:42.4万
展开全部

<s:select

list="%{#session.sub}" //存放在httpSession的list集合

listKey="sname" //下拉列表要中列表框要显示的值

listValue="sname"//下拉列表的值

key="sname"    

id="subject"    

name="subject" //存放在httpSession的值,主要判断是否被选中时候用的

onchange="c(1)"

theme="simple">
</s:select>

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式