为什么我按照学号查询查哪个学号都是查出全部,下边有我的代码,哪位大神会的,求详解求改正谢谢了

action对应的代码:

private int xueHao;
public String getList() throws Exception
{
xueshengList = dao.getList(xueHao);
return SUCCESS;
}

 public int getXueHao() {
    return xueHao;
}

public void setXueHao(int xueHao) {
    this.xueHao = xueHao;
}

DAOA里代码:

public List getList(int xh)
{
String where="";
if(xh!=0)
{
where=where+" where xueHao="+xh+"";
}
return this.findAll(where);
}

findAll方法:
private List<Xuesheng>  findAll(String where)
{
       Session sess = this.getSessionFactory().openSession();
         try
         {
          Query query = sess.createQuery(" From  Xuesheng " + where + " order by id ");
          return query.list();
         }
         finally
         {
            sess.close();
         }
查看全部
baidu_29643173
baidu_29643173
2015/07/09 01:24
  • java
  • web
  • struts
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复