【发布时间】:2015-12-14 15:54:34
【问题描述】:
我正在使用Spring Boot 将.war 文件部署到external Tomcat Server。
我正在使用Ajax/Restful 身份验证,并且我有以下处理身份验证失败的类:
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, exception.getMessage());
}
当我使用嵌入式 Tomcat 服务器时,一切顺利,在身份验证失败时,我得到以下 JSON:
{
"timestamp" : "2015-12-14T15:39:07.365+0000",
"status" : 401,
"error" : "Unauthorized",
"message" : "You have provided wrong credentials",
"path" : "/api/authentication"
}
但是,当使用External Tomcat Server 时,我得到一个HTML 响应,这会带来通常的Tomcat 身份验证失败页面。有什么办法可以绕过外部服务器?
【问题讨论】:
标签: ajax spring tomcat authentication spring-boot