Java设置SetCookie属性

在Controller层里加上

1
2
3
4
5
6
7
/**
* 设置HttpOnly=true,SameSite=secure,Secure=true
*/
@ModelAttribute
public void setReqAndRes(HttpServletRequest request, HttpServletResponse response){
response.setHeader("Set-Cookie", response.getHeader("Set-Cookie")+";SameSite=strict;HttpOnly;Secure=true");
}