public String execute() throws Exception {
List<Category> list=categoryService.queryByname(new String(getName().trim().getBytes("ISO8859-1"),"UTF-8")); if(!list.isEmpty()){ //不可以用list==null 不知为什么 ServletActionContext.getRequest().setAttribute("list", list);
return SUCCESS;
}else{
return "noresult";
}
}
我用list==null 永远都到不了第二个视图 他们到底什么区别
List<Category> list=categoryService.queryByname(new String(getName().trim().getBytes("ISO8859-1"),"UTF-8")); if(!list.isEmpty()){ //不可以用list==null 不知为什么 ServletActionContext.getRequest().setAttribute("list", list);
return SUCCESS;
}else{
return "noresult";
}
}
我用list==null 永远都到不了第二个视图 他们到底什么区别
解决方案 »
- 100分求教一个struts配置问题 跟帖有分
- 请问HttpSessionBindingListener怎么设置超时退出
- 遇到个seam 问题 帮帮忙
- struts2配置文件问题
- struts2.0的文件上传问题
- 用 struts2 标签Hibernate的多表查询问题
- 做好一张比较完美的网站,需要那些步骤.....
- struts+hibernate下运行实例的错误---急、在线等!
- 如何使用weblogic platform8.1
- EJB的好书,请推荐,我看了<精通EJB2.0>,好薄哟!!
- 使用了Hibernate框架,查询数据库时查不到,抛出异常。怎么办
- hibernate 插入乱码问题
boolean isEmpty()如果列表不包含元素,则返回 true。 指定者:
接口 Collection<E> 中的 isEmpty
返回:
如果列表不包含元素,则返回 true这个是API 里面的说法。
int size()返回列表中的元素数。如果列表包含多于 Integer.MAX_VALUE 个元素,则返回 Integer.MAX_VALUE。 指定者:
接口 Collection<E> 中的 size
返回:
列表中的元素数可是 使用这个
List <Category> list=categoryService.queryByname(new String(getName().trim().getBytes("ISO8859-1"),"UTF-8")); if(list != null && !list.isEmpty()){ //不可以用list==null 不知为什么 ServletActionContext.getRequest().setAttribute("list", list);
return SUCCESS;
}else{
return "noresult";
} }
如果 list == null 是根本没有创建对象 。
isEmpty 方法是判断LIST 是否为空, 对象已经创建。不知道你方法里面怎么写的, 应该是查询方法返回了空的集合。