findByExample(Object exampleEntity)方法得到的List判断是否为空,不可用(lis != null)

用findByExample(Object exampleEntity)方法可以应用在用户登录上面,获得有登陆名和密码的user对象进行查询。

返回两者都符合的对象列表,为空则登陆失败。

 

错误的方法:

1 List list = null;
2 this.setlist(result);
3 
4 if(list != null){
5     return SUCCESS;
6 }else{
7     return INPUT;
8 }

 

正确的方法:

1 List list = null;
2 this.setlist(result);
3 
4 if(list.size() != 0){
5     return SUCCESS;
6 }else{
7     return INPUT;
8 }

 

不知道为啥。

posted @ 2013-12-07 18:43  Liuxiaoke  阅读(606)  评论(0编辑  收藏  举报