这里的value对应的值能不能用变量表示

 public List<Godness> query(List<Map<String,Object>> params) throws SQLException {
        Connection conn=DbUnit.getConnection();
        StringBuilder sb=new StringBuilder();
        sb.append("select * from godness where 1=1 ");
        if(params!=null && params.size()>0){
            for(int i=0;i<params.size();i++){
                Map<String,Object> map=params.get(i);
                sb.append(" and "+map.get("name")+" "+map.get("rela")+" "+map.get("value")+" ");
            }
        }
        PreparedStatement ps=conn.prepareStatement(sb.toString());


 List<Map<String,Object>> params=new ArrayList<Map<String,Object>>();
                      Map<String,Object> param=new HashMap<String,Object> ();
                      param.put("name", "user_name");
                      param.put("rela","=");
                      param.put("value","'小花'");
                      params.add(param);
                     List<Godness> g2= g.query(params);

qq_水鬼_0
浏览 1853回答 3
3回答

慕用0833797

可以的,只要你类型匹配上就可以

方丈遗少杜三贱

肯定是可以的啊。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
MySQL