public List<TUser> getAllUsersByPage(TUser user, Pager pager) {
String sql = "from TUser where groupId != 0";
if (user != null){
if (user.getUserName() != null && !user.getUserName().equals("")){
sql += " and userName like '%" + user.getUserName() +"%'";
}
}
if(user !=null){
if(user.getGroupId() !=null && !user.getGroupId().equals("")){
sql +=" and groupId = "+ user.getGroupId() +" ";
}
}
所报异常如下:
unexpected token: 2 near line 1, column 70 [from com.tcs.sysmanager.pojo.TUser where groupId != 0 and groupId in 2 ]
String sql = "from TUser where groupId != 0";
if (user != null){
if (user.getUserName() != null && !user.getUserName().equals("")){
sql += " and userName like '%" + user.getUserName() +"%'";
}
}
if(user !=null){
if(user.getGroupId() !=null && !user.getGroupId().equals("")){
sql +=" and groupId = "+ user.getGroupId() +" ";
}
}
所报异常如下:
unexpected token: 2 near line 1, column 70 [from com.tcs.sysmanager.pojo.TUser where groupId != 0 and groupId in 2 ]
解决方案 »
- The requested resource is not available
- DAO模式插入数据库数据问题!
- chrome游览器的问题
- 怎样在jsp页面下得到焦点控件的名字?
- 如何用java将图片制作水印效果(急急,请高手帮忙)高分!!!!!!!
- 求一个select,可以输入选项的
- 像新浪那样滚动播放新闻的功能是怎样实现的
- <?为何我的servlet不可以运行?>
- 如何在jsp中调用active控件?小女子先谢过了!
- 火烧到我的眉毛了!!!!!!!!!!好急啊!!!!!!!!!!!在线等待
- 请问一个关于在HTML中显示EXCEL的问题,我实在没办法了!
- 寻求一个获得数据库中自动增加的id号的值的方法!
StringBuffer sql=new StringBuffer("from CstCustomer ct where 1=1");
if(ct.getCustNo()!=null){
if(!ct.getCustNo().equals("")){
sql.append(" and ct.custNo like :custNo");
}
}
if(ct.getCustName()!=null){
if(!ct.getCustName().equals("")){
sql.append(" and ct.custName like :custName");
}
}
if(ct.getCustRegion()!=null){
if(!ct.getCustRegion().equals("") && !ct.getCustRegion().equals("全部")){
System.out.println(ct.getCustRegion());
sql.append(" and ct.custRegion like :custRegion");
}
}
if(ct.getCustManagerName()!=null){
if(!ct.getCustManagerName().equals("")){
sql.append(" and ct.custManagerName like :custManagerName");
}
}
if(ct.getCustLevelLabel()!=null){
if(!ct.getCustLevelLabel().equals("") && !ct.getCustLevelLabel().equals("全部")){
sql.append(" and ct.custLevelLabel like :custLevelLabel");
}
}
异常表示是不识别你写的那个SQL语句
String sql = "from TUser t where t.groupId != 0";
在后面的字段后面都加个t.试试
咋 感觉你的这个单引号是全角的一样