springboot+thymeleaf接收前台传来的request,在js里获取到后台向前台传递的request

创建controller方法

@GetMapping("/test")

public String test(HttpServletRequest request){

String openid = request.getParameter("openid");//接收传来的openid
request.setAttribute("openid", openid);//将openid 放入request

return "user/test"; //这里指的是static/user/test.html    跳转到这个页面

}

前端页面接收request

 

然后在js里这样获取这个属性

var openid= document.getElementById("openid").value;

你可能感兴趣的:(Springboot)