本文整理汇总了Java中javax.servlet.http.HttpServletResponse.addIntHeader方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.addIntHeader方法的具体用法?Java HttpServletResponse.addIntHeader怎么用?Java HttpServletResponse.addIntHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.http.HttpServletResponse
的用法示例。
在下文中一共展示了HttpServletResponse.addIntHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCORSHeaders
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private void addCORSHeaders(HttpServletRequest request, HttpServletResponse response) {
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, HEAD, OPTIONS");
response.addHeader("Access-Control-Allow-Headers", "Authorization, Content-Type");
response.addHeader("Access-Control-Allow-Credentials", "true");
response.addIntHeader("Access-Control-Max-Age", 1728000);
}
示例2: doFilter
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
try {
if (servletResponse instanceof HttpServletResponse) {
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
String uri = httpServletRequest.getRequestURI();
if (this.enableCacheControl && !uri.endsWith(".css") && !uri.endsWith(".js") && !uri.endsWith(".png") && !uri.endsWith(".jpg") && !uri.endsWith(".ico") && !uri.endsWith(".jpeg") && !uri.endsWith(".bmp") && !uri.endsWith(".gif")) {
httpServletResponse.addHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
httpServletResponse.addHeader("Pragma", "no-cache");
httpServletResponse.addIntHeader("Expires", 0);
LOGGER.fine("Adding Cache Control response headers for " + uri);
}
if (this.enableStrictTransportSecurity && servletRequest.isSecure() &&
this.hasNoHeaderValue(httpServletResponse, "Strict-Transport-Security", "max-age=15768000; includeSubDomains")) {
httpServletResponse.addHeader("Strict-Transport-Security", "max-age=15768000; includeSubDomains");
LOGGER.fine("Adding HSTS response headers for " + uri);
}
if (this.enableXContentTypeOptions &&
this.hasNoHeaderValue(httpServletResponse, "X-Content-Type-Options", "nosniff")) {
httpServletResponse.addHeader("X-Content-Type-Options", "nosniff");
LOGGER.fine("Adding X-Content Type response headers for " + uri);
}
if (this.enableXFrameOptions &&
this.hasNoHeaderValue(httpServletResponse, "X-Frame-Options", "DENY")) {
httpServletResponse.addHeader("X-Frame-Options", "DENY");
LOGGER.fine("Adding X-Frame Options response headers for " + uri);
}
if (this.enableXSSProtection &&
this.hasNoHeaderValue(httpServletResponse, "X-XSS-Protection", "1; mode=block")) {
httpServletResponse.addHeader("X-XSS-Protection", "1; mode=block");
LOGGER.fine("Adding X-XSS Protection response headers for " + uri);
}
}
} catch (Exception var7) {
FilterUtils.logException(LOGGER, new ServletException(this.getClass().getSimpleName() + " is blocking this request. Examine the cause in this stack trace to understand why.", var7));
}
filterChain.doFilter(servletRequest, servletResponse);
}