需跳转接口
@RestController
@CrossOrigin
@PostMapping("/gotoCarkeeper")
public void gotoCarkeeper(HttpServletResponse response
) throws IOException
{
Member member
= memberMapper
.selectByPrimaryKey(UserUtils
.getThisMobileUser().getId());
WxMpUserConfig wxUser
= wxMpUserMapper
.findWxUserByMemberId(member
.getMemberId());
JSONObject jsonObject
= new JSONObject();
jsonObject
.put("member",member
);
jsonObject
.put("wxUser",wxUser
);
doPost(jsonObject
);
}
public static JSONObject
doPost(JSONObject date
) {
HttpClient client
= HttpClients
.createDefault();
String url
= "http://localhost:8082/weixin/chichengToLocal";
HttpPost post
= new HttpPost(url
);
JSONObject jsonObject
= null
;
try {
StringEntity s
= new StringEntity(date
.toString());
s
.setContentEncoding("UTF-8");
s
.setContentType("application/json");
post
.setEntity(s
);
post
.addHeader("content-type", "text/xml");
HttpResponse res
= client
.execute(post
);
String response1
= EntityUtils
.toString(res
.getEntity());
System
.out
.println(response1
);
if (res
.getStatusLine().getStatusCode() == HttpStatus
.SC_OK
) {
String result
= EntityUtils
.toString(res
.getEntity());
jsonObject
= JSONObject
.parseObject(result
);
}
} catch (Exception e
) {
throw new RuntimeException(e
);
}
return jsonObject
;
}
跳转接口(接收方)
@CrossOrigin
@RequestMapping("chichengToLocal")
public String
chichengToLocal(@RequestBody String content
){
JSONObject json
= (JSONObject
) JSONObject
.parse(content
);
String member
= json
.getString("member");
String wxUser
= json
.getString("wxUser");
return "index";
}
转载请注明原文地址: https://lol.8miu.com/read-29493.html