<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";
} 展开
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";
} 展开
1个回答
展开全部
<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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |