微信openid和已有系统的用户绑定

微信公众号提供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;
		}
	}
}

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值