总体思路:map传值
controller:
Mapm=new HashMap (); m.put("name", 'zs'); m.put("password", '55555'); cardservice.bindCard(m); JSONObject json=new JSONObject(); //获得返回值 json.put("msg", m.get("msg")); json.put("result", m.get("result"));
service:
@Override public Object bindCard(Mapm) { try { return cardMapper.bindCard(m); } catch (Exception e) { e.printStackTrace(); return new HashMap (); } }
mapper:
Object bindCard(Mapmap) throws Exception;
20180522另一种方法:
mapper:
List
service
List
controller
@RequestMapping(value = "/getQuestionAnswerByModulesId", method = RequestMethod.POST) @ResponseBody public JSONObject getQuestionAnswerByModulesId(HttpServletRequest req,int modulesId) { JSONObject json = new JSONObject(); try { @SuppressWarnings("unchecked") Mapmap=(Map )req.getSession().getAttribute("user"); List > list = naireService.getQuestionAnswerByModulesId(modulesId,(String)map.get("PatientCode")); json.put("questionList", list); json.put("result", true); json.put("msg", "获取相应模块成功!"); } catch (Exception e) { json.put("result", false); json.put("msg", "获取相应模块失败!"); logger.error("getQuestionByModulesId异常!", e); } return json; }
20180810:
注意,切换数据源时,调用存储过程时不能开启事物,否则不能切换数据源
20181023
今天要获得存储过程的返回值,但不想用call方法感觉太麻烦,网上也没找到资料,研究了一下可如此解决: