|
楼主 |
发表于 2018-8-24 09:37:50
|
显示全部楼层
本帖最后由 吕巍 于 2018-8-24 09:39 编辑
传递参数没问题了,但是调用action还是不行呢,直接在action中直接写个map就可以调用成功,try语句开始那两句- public static Table QueryPro(Map ParamMap,String ProName){
- java.sql.Connection conn;
- //字符串截取
- try { //Map sMap = new HashMap();
- //sMap.put("吕巍", "String");
- conn = com.justep.model.ModelUtils.getConnection("/yongyoujicheng/MRPqinggou/data"); //更改数据源
- java.sql.CallableStatement proc = conn.prepareCall("{call "+ProName+ParamSeparate(ParamMap)+"}"); //更改ACCTION名
- int i = 0;
- Iterator<Entry<String, String>> entries = ParamMap.entrySet().iterator();
- while (entries.hasNext())
- {
- Map.Entry entry = (Map.Entry) entries.next();
- String key = (String)entry.getKey();
- String value = (String)entry.getValue();
- if(value=="String")
- {
- i++;
- proc.setString(i, key);
- }
- }
-
- ResultSet rt = proc.executeQuery();
- Table table = com.justep.system.util.BizUtils.resultSet2Table(rt,"/yongyoujicheng/MRPqinggou/data");
- return table;
- }
- catch (NamingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- }
- public String ParamSeparate(Map N){
- String s="(";
- Iterator<Entry<String, String>> entries = N.entrySet().iterator();
- while (entries.hasNext())
- {
- Map.Entry entry = (Map.Entry) entries.next();
- s = s + "?,";
- }
- s = s.substring(0,s.length()-1);
- s = s+")";
-
- return s;
复制代码
|
|