<html>
<head><title>Simple jsp page</title></head>
<body>
<s:form>
<s:select list="educations" label="最高学历" name="education" listKey="id" listValue="name"/>
</s:form>
</body>
</html>
报出异常为:
org.apache.jasper.JasperException: tag 'select', field 'list', name 'education': The requested list key 'educations' could not be resolved as a collection/array/map/enumeration/iterator type.
有没有高手解决一下。
<head><title>Simple jsp page</title></head>
<body>
<s:form>
<s:select list="educations" label="最高学历" name="education" listKey="id" listValue="name"/>
</s:form>
</body>
</html>
报出异常为:
org.apache.jasper.JasperException: tag 'select', field 'list', name 'education': The requested list key 'educations' could not be resolved as a collection/array/map/enumeration/iterator type.
有没有高手解决一下。
解决方案 »
- 如何用正则表达式截取网页内容的问题!
- Exception:Unable to locate Spring NamespaceHandler for XML schema namespace
- 一个tomcat启动问题;
- 如何打印出SQL语句,谢谢!
- 难点,精点,控讨HTML的frame
- 哪位有网上商城的源代码,请给我一份,谢谢
- 关于类的简单问题,看了再说!急!!!
- 设置jdk得时候不小心删掉了path
- 关于displaytag标签的问题,高手快来
- 建网站的数据库用哪种开发语言比较好?
- 用struts 2 +myeclipse写文件上传时,处理找不到指定的路径的问题?
- jsp如何动态生成伪静态网页
<s:select list="educations" label="最高学历" name="education" listKey="id" listValue="name"/>请确定是以下这些类型中的一种collection/array/map/enumeration/iterator
private List<Education> educations;
public Educations()
{
educations=new ArrayList<Education>();
educations.add(new Education(1,"高中生") );
educations .add(new Education(2,"大学生"));
educations .add(new Education(3,"硕士生"));
}
public String execute()throws Exception
{
return SUCCESS;
}
public void setEducations(List<Education> educations) {
this.educations = educations;
}
public List<Education> getEducations() {
return educations;
}
可是 就是不对。 那位高手指点一下!
private int Id;
private String name;
public Education()
{}
public Education(int Id,String name)
{
this.Id=Id;
this.name=name;
}
public void setId(int id) {
Id = id;
}
public int getId() {
return Id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
看下是不是这里的问题
{
educations=new ArrayList<Education>();
educations.add(new Education(1,"高中生") );
educations .add(new Education(2,"大学生"));
educations .add(new Education(3,"硕士生"));
}把构造函数中的
educations=new ArrayList<Education>();
educations.add(new Education(1,"高中生") );
educations .add(new Education(2,"大学生"));
educations .add(new Education(3,"硕士生")); 写到 execute方法中。
你定义这个List是做什么用的?是从前台接收数据,还是为了创建对象?
你这代码写的一点逻辑性都没有。在写代码前考虑考虑每个属性你创建了要起什么作用先。盲目动手没什么效果的。再者,你传值的话,通过什么传,用什么接,接到了怎么处理?这些你都考虑下。
public void findEduList() throws ENMSException {
ActionContext ctx = ActionContext.getContext();
List<Education> list = new ArrayList<Education>();
list .add(new Education(1,"高中生") );
list .add(new Education(2,"大学生"));
list .add(new Education(3,"硕士生"));
ctx.put("eduList", list);
} <s:select list="%{eduList}" name="Id" listKey="Id"
listValue="name" id="Id"
headerKey="-1
headerValue="--请选择--">
</s:select>
ognl%{list="educations" }
才能取得相应的值
改成 <s:select list="%{educations}" label="最高学历" name="education" listKey="id" listValue="name"/>
试试, 也就是把OGNL中的字符串转换当做OGNL表达式解析,另楼主可仔细参考13楼的,这个应该没问题
<s:select name="operator" list="#{'编辑','员工','作者'}" label="操作人" /> <br>
为什么会出现上边的出错信息?
求解