2019-12-30 15:08

@JFinal //web端扫码登陆
public void index() throws ApiException{
DefaultDingTalkClient client=new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode");
OapiSnsGetuserinfoBycodeRequest req=new OapiSnsGetuserinfoBycodeRequest();
req.setTmpAuthCode(getPara("code"));
OapiSnsGetuserinfoBycodeResponse response=client.execute(req,"dingoa6anbucxldra86g9q","xptFam_8drO-wuNGKKQTkjgdMLxhs0Nyj6j9s0uGEAa-doZVUfDmmqtxlhR0koU5");
String dingtoken=AccessTokenUtil.getToken();
//获取UserId
DingTalkClient client2=new DefaultDingTalkClient("https://oapi.dingtalk.com/user/getUseridByUnionid");
OapiUserGetUseridByUnionidRequest request2=new OapiUserGetUseridByUnionidRequest();
request2.setUnionid(response.getUserInfo().getUnionid());
request2.setHttpMethod("GET");
OapiUserGetUseridByUnionidResponse userInfo=client2.execute(request2,dingtoken);

if(0==userInfo.getErrcode()) {
//获取用户详情
DingTalkClient client3=new DefaultDingTalkClient("https://oapi.dingtalk.com/user/get");
OapiUserGetRequest request=new OapiUserGetRequest();
request.setUserid(userInfo.getUserid());
request.setHttpMethod("GET");
OapiUserGetResponse response3=client3.execute(request,dingtoken);
UsernamePasswordToken token=new UsernamePasswordToken(userInfo.getUserid(),userInfo.getUserid());
Subject subject=SecurityUtils.getSubject();
subject.login(token);
subject.getSession().setAttribute("user", response3);

//redirect("/index");
render(new RedirectRender("/index"));

}else {
//redirect("/loginInit?code=1&icon=5");
render(new RedirectRender("/loginInit?code=1&icon=5"));
}
}
之前用的是redirect("/index");后面根据你的提示换成了render(new RedirectRender("/index"));然后就好了~

2019-12-30 13:43

@JFinal 放开75行注释页面跳转没问题了~

2019-12-30 11:47

http协议下,扫码登陆成功之后页面跳转,是有端口值的,不知道为什么配置了https之后,扫码成功之后页面跳转就少了端口值???