【发布时间】:2017-12-29 02:34:02
【问题描述】:
我收到threw exception
java.lang.IllegalStateException: getWriter() has already been called for this response
at org.apache.catalina.connector.Response.getOutputStream(Response.java:544)
在从 angular2 通信我的服务器端代码(RESTFul、Spring-boot)时。两者都部署在同一台服务器上(Tomcat 8.0.2)。
以下是我的代码
@RequestMapping(value="/login", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public User login() {
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
User user = (User) principal;
return user;
}
如何解决这个问题?
【问题讨论】:
-
用代码告诉我们你想要做什么。一旦调用了作者,您似乎正在调用 getWriter()。
-
我正在尝试进行宁静的基本身份验证。当我从我的客户端登录时,我得到了这个异常。在登录期间,我从安全上下文对象返回经过身份验证的用户
-
请分享最少的代码。
标签: spring tomcat spring-boot tomcat8 restful-authentication