package com.xgk.action; import java.io.IOException; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import com.xgk.Test.Sign; import com.xgk.entity.Access _ token; import com.xgk.entity.Ticket; import com.xgk.entity.Token; import com.xgk.entity.User; import com.xgk.service.UserService; import com.xgk.util.GetAccess _ token; import com.xgk.util.GetJsapi_ticket; import com.xgk.util.GetToken; import com.xgk.util.SHA1; @Controller @RequestMapping(“/”)public class UserOpenid {@Autowired private UserService userService;
private static final String APPID =“wxad2947b0d6904a98”;
private static final String SECRET =“29cff6bd6f765198f48b30035a453bea”;
private String openid =“”;
@RequestMapping(value =“/ getUserBybase”)
public String getUserBybase(@RequestParam(“code”)字符串代码,HttpServletRequest请求)抛出IOException {//静默授权方便授权用户进行二次登录
令牌令牌=新GetToken ()。getToken(代码,APPID,SECRET);
的OpenID = token.getOpenid();
if(userService.selectopenid(openid)== null){
return“login / login.html”; //跳到登录页面
}
Access_token tokens = new GetAccess_token()。getAcc(APPID,SECRET);
Ticket ti = new GetJsapi_ticket()。getTicket(tokens.getAccess_token());
String url = request。
Map <String,String> ret = new Sign()。getSig(ti.getTicket(),url);
for(Map.Entry entry:ret.entrySet()){
request.setAttribute(entry.getKey()。toString(),entry.getValue());
}
return“view / welcome.jsp”;
}
@RequestMapping(value =“/ login”)
public String login(User user){
User users = userService.selectLogin(user);
users.setOpenid(的的的的的的的的的的的的OpenID的);
userService.updateopenId(用户); 返回“view / video.html”;
}}
//为什么使用微信的signature工具类跟接口测试的不一样。。。。
-引用 CTRL + Q
-插入链接’按用菜单调用插入代码’打字代理’打样代理’按下按Ctrl键键键键按住Ctrl键键键键按用键Ctrl键键键键按住Ctrl键键键按住按代代代代代代代代键+ +
- 插图图
''按'CTRL + G' - 提升标题
按Ctrl +具体代表,企业名称空间管制+方式列表有效列表
有效可编程键盘键控按钮- 无序列表``按CTRL + U.由按CTRL + U. 1.按顺时针方向盘锁定,在改设方向上划线,然后按顺时针方向选择 - 撤销
按按按按Ctrl + Z.` - 重做“按Ctrl键+ Y键”##减价及扩展>降价是一种轻量级标记语言,它允许人们使用易读易写的,然后转换成格式丰富的HTML页面.a href =“https :// zh.wikipedia.org/wiki/Markdown”target =“_ blank”> [维基百科]使用简单的符号标识不同的标题,将某些文字标记为* 粗体或者斜体,创建一个[(http:// www.csdn .net)等,详细语法参考帮助?。本编辑器支持 Markdown额外 ,扩展了很多好用的功能。具体请参考[Github] [2]脚注生成一个脚注[^] [^脚注:这里是 脚注 * * 的内容使用MathJax渲染 * LaTex的数学公式,见[数学。stackexchange.com] [1]。