开发者社区> 问答> 正文

ssh 框架服务器乱码 解决乱码后 hibernate 查询功还能不能实现了啊?

ssh -----------dao层代码

public List<Community> searchByCommunityname(String comName) {

        // TODO Auto-generated method stub
        System.out.println("dao----------"+comName);
        try {
            System.out.println("beging--------------------");
            final String hql="from Community where communityName like '"+comName+"%' ";
            Query query=getSession().createQuery(hql);
            System.out.println("end----------------------");
            
            return query.list();
            
        } finally{
            releaseSession(getSession());//关闭session
        }
    }

ssh -----------action代码

public String getCom(){
            //解决服务器上乱码
            //String str=comName;
            keyCom="searchCom";
            dataMap=new HashMap<String, Object>();
            List<Community> lstComSearch=null;
            try {
                System.out.println("+++++"+comName);
                lstComSearch=communityService.searchByCommunityname(comName);
                System.out.println("-------------"+lstComSearch.size());
                dataMap.put(keyCom, lstComSearch);
                dataMap.put("result", 1);
            } catch (Exception e) {
                // TODO: handle exception
                dataMap.put(keyCom, null);
                dataMap.put("result", 0);
            }
            return "comSuccess";
        }

服务器请求:

http://101.200.81.142:8080/hlsh/mobile_getCom?comName=鸳鸯

http://101.200.81.142:8080/hlsh/mobile_getCom?comName=s

展开
收起
爵霸 2016-03-04 11:21:43 2066 0
1 条回答
写回答
取消 提交回答
  • screenshot

    2019-07-17 18:51:59
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS快储存加密技术 立即下载