public class GeneralWebFilter extends Object
目前支持: 自定义响应头,在 HTTP 响应头信息中的 X-Frame-Options,可以指示浏览器是否应该加载一个 iframe 中的页面。 如果服务器响应头信息中没有 X-Frame-Options,则该网站存在 ClickJacking 攻击风险。 网站可以通过设置 X-Frame-Options 阻止站点内的页面被其他页面嵌入从而防止点击劫持。 添加 X-Frame-Options 响应头,赋值有如下三种: 1、DENY: 不能被嵌入到任何iframe或者frame中。 2、SAMEORIGIN: 页面只能被本站页面嵌入到iframe或者frame中。 3、ALLOW-FROM uri: 只能被嵌入到指定域名的框架中。
例如:
<init-param> <param-name>responseHeaders</param-name> <param-value>X-Frame-Options=SAMEORIGIN</param-value> </init-param>注:多个响应头之间采用'|'分隔
Constructor and Description |
---|
GeneralWebFilter() |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain) |
void |
init(FilterConfig filterConfig) |
public void init(FilterConfig filterConfig) throws ServletException
ServletException
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
IOException
ServletException
public void destroy()
Copyright © 2022. All rights reserved.