是否可以拦截向客户端发送的响应,并在最终发送修改后的响应?
我想从基本身份验证响应中删除“WWW-Authenticate”标头,或者在错误的身份验证情况下将错误代码从 401 更改为 403。
附:我也有同样的问题:http://www.java.net/forum/topic/glassfish/glassfish/suppress-www-authenticate-header-if-basic-auth-fails http://www.java.net/forum/topic/glassfish/glassfish/suppress-www-authenticate-header-if-basic-auth-fails
我尝试将 Filter 与 HttpServletResponseWrapper 一起使用,但在 JAAS 基本 HTTP 身份验证之前从未调用过我的 Filter。我通过下一个代码解决了烦人的弹出窗口的问题
在 web.xml 中:
<error-page>
<error-code>401</error-code>
<location>/error.jsp</location>
</error-page>
错误.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<%
int status = response.getStatus();
if (status == 401) {
response.setStatus(403);
}
%>
</body>
</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)