當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletResponse.addIntHeader方法代碼示例

本文整理匯總了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);
    }
 
開發者ID:tmply,項目名稱:tmply,代碼行數:9,代碼來源:CORSFilter.java

示例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);
}
 
開發者ID:e-gov,項目名稱:TARA-Server,代碼行數:39,代碼來源:ResponseHeadersEnforcementFilter.java


注:本文中的javax.servlet.http.HttpServletResponse.addIntHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。