A action 和B action 不在一个服务器上,A action需要使用B action的返回值(不是页面,是数据),问一下这个怎么弄?
A action:
A action:
@ApiOperation(value = "新增 用户", notes = "新增用户") @RequestMapping(method = RequestMethod.POST) public User insert(@ApiParam(value = "用户", required = true) @RequestBody User user) { // 调用B action 的保存 return user; }
B action:
@ResponseBody @RequestMapping(value = "/user/save", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Map<String, Object> saveUser(@RequestParam(value = "param") Map<String, Object> paramMap) throws E5Exception { // 验证接口调用方的身份 if (!ControllerHelper.valid(paramMap.get("token").toString())) { return ControllerHelper.createFailMap("参数提供的token不合法!"); } User user = (User) paramMap.get("user"); return userBaseService.saveUser(user); }
解决方案
10
直接http请求B就可以了.
30
早上大意了, 没看清楚B类接收参数是@RequestParam(value = “param”), 本人也没搞出来, 假如可以改B的话可以将@RequestParam改为@RequestBody接收参数. 亲测可以.