在开发网页授权获取用户基本信息时code是null
在开发网页授权获取用户基本信息时,第一步的获取code时获取到的是null 网页授权获取用户基本信息,url地址是: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7d24a6105455ffae&redirect_uri=http%3A%2F%2Fmobileotc.999.com.cn%2Fstore%21loginCode.action&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect ,请问这是什么原因?
代表如下:
String url = Constants.DOMAIN+"/store!loginCode.action";
StringBuffer sb = new StringBuffer("https://open.weixin.qq.com/connect/oauth2/authorize?");
sb.append("appid=").append(Constants.APPID);
try {
sb.append("&redirect_uri=").append(URLEncoder.encode(url, "utf-8"));
sb.append("&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
log.info("loginWeiXin url:"+sb.toString());
response.sendRedirect(sb.toString());
} catch (IOException e) {
log.info(e.getMessage());
}
获取代表如下:
String code= request.getParameter("code");
log.info("loginCode:"+code);
打印出来的信息是loginCode:null
Elawh
9 years, 10 months ago