I try to add a Cookie by aop,but it dosent work.I cant find the Cookie in Browser. I guess the HttpServletResponse only Could be changed in a Controller.
@Aspect
@Component
public class AspectDemo
{
@Before("execution(* com.example.demo.controller.RestfulController.rest(..))")
void beforeLogin(JoinPoint joinPoint)
{
HttpServletResponse httpServletResponse= (HttpServletResponse) joinPoint.getArgs()[0];
httpServletResponse.addCookie(new Cookie("TestAttribute","test"));
}
}