我得到threw exception java.lang.IllegalStateException: getWriter() has already been called for this response at org.apache.catalina.connector.Response.getOutputStream(Response.java:544)
如何解決這個IlleagalstateException在訪問部署在Tomcat上的restful spring-boot應用程序?
同時通過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;
}
怎樣才能解決這個問題?
告訴我們的代碼你正在嘗試做的。看起來你一旦調用writer就調用getWriter()。 – Barath
我正在嘗試執行安靜的基本身份驗證。當我從我的客戶端登錄時,我收到了這個異常。在登錄期間,我從安全上下文對象 – Prince
返回經過身份驗證的用戶請分享最少的代碼。 – Barath