我使用以下代码在JAVA中创建 session
request.getSession().setAttribute("popMSG","Service removed successfully");
或者如果发生错误
request.getSession().setAttribute("popMSGF","Oops something went wrong!");
我需要在我的 AngularJS 函数中获取此 session ,代码如下。
msg(value_from_angularJS)
最佳答案
您需要在后端代码中创建另一个端点,以便客户端获取信息。例如:
public String getMessage() {
//This is spring code may be different from your code.
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // This is spring code may be different with your code.
return request.getSession().getAttribute("popMSGF");
}
关于java - 如何在AngularJS中使用JAVA创建的 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42712453/