微信公众号提供OAuth2.0验证,但是如果在只想用openid,则只需自己的业务平台把openid和已有的用户名绑定即可。
但这种方式绑定有个弊端,下一篇重写个按微信文档的:
按微信文档写的:https://blog.csdn.net/hongmin118/article/details/89305861
所有的操作必须要到微信页发起,也就是说,点击“我的数据”->后台判断没绑定->返回消息给微信->用户在微信信息中点击“绑定”,才能再跳转到"绑定页面",而且即使已经绑定,也得返回消息给微信,然后点击微信聊天记录中的“数据”,才能跳转到mydata.jsp
流程图:
springmvc中,设置controller既可以返回ajax,又可以返回跳转:
@Controller
@RequestMapping("/test1")
public class DemoAction extends BaseAction {
@Resource
Tbtest1Service tbtest1Service;
/**
* 该方法既可以走ajax,又可以走跳转(reword或redirect)
* @param request
* @param response
* @return
* @throws IOException
*/
@RequestMapping("/twopath")
public Object ajaxPaymentBatchApproveProcess(HttpServletRequest request,
HttpServletResponse response) throws IOException {
String type = request.getParameter("type");
if (type == null || type.equals("1")) {
return "redirect:/jsp/index2.jsp";
// return new ModelAndView("redirect:/jsp/index2.jsp");
// return "redirect:/index2.jsp";
// ModelAndView view = new ModelAndView();
// view.setView(new RedirectView("/index2.jsp", false));
// return view;
} else if ((type.equals("2"))) {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(JSON.toJSONString("123123"));
out.flush();
out.close();
return null;
} else {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(JSON.toJSONString("空空"));
out.flush();
out.close();
return null;
}
}
}