CSS и JS Не удалось загрузить с фильтром безопасности esapi во время обновления
В моем проекте мы используем фильтр безопасности esapi. Проблема в том, что при обновлении браузера мы получаем следующую ошибку в Firefox. Если мы обновляем страницу снова, страница загружается правильно. Но в другое время она не работает.
Ресурс из " http://localhost:8080/selva/css/bootstrap.css" был заблокирован из-за несоответствия типов MIME (X-Content-Type-Options: nosniff)
В chrome мы получаем ошибку ниже, но она приходит случайным образом для каждых 20 запросов. Но обновление не пришло.
Ресурс интерпретируется MIMEType('') не удалось
Когда я комментирую фильтр безопасности esapi, вышеупомянутые проблемы не возникают. ниже мой web.xml
<filter>
<filter-name>selva_security</filter-name>
<filter-class>
com.selva.security.core.SelvaSecurityFilter
</filter-class>
<init-param>
<param-name>isContentSetRequired</param-name>
<param-value>No</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>selva_security</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Если я прокомментирую фильтр. Все работает нормально.
Ниже мой класс фильтра
public class SelvaSecurityFilter implements Filter {
private String allowableResourcesRoot = "WEB-INF";
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try {
HttpServletRequest hrequest = (HttpServletRequest) request;
HttpServletResponse hresponse = (HttpServletResponse) response;
SecurityWrapperRequest secureRequest = new SecurityWrapperRequest(hrequest);
SecurityWrapperResponse secureResponse = new SecurityWrapperResponse(hresponse);
secureRequest.setAllowableContentRoot(allowableResourcesRoot);
ESAPI.httpUtilities().setCurrentHTTP(secureRequest, secureResponse);
hresponse.addHeader("X-Content-Type-Options", "nosniff");
hresponse.setHeader("X-Powered-By", "");
hresponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
hresponse.setHeader("Pragma", "no-cache"); // HTTP 1.0.
hresponse.setDateHeader("Expires", 0); // Proxies.
} catch (Exception e) {
}
finally {
}
}
public void init(FilterConfig filterConfig) throws ServletException {
this.allowableResourcesRoot = StringUtilities.replaceNull(filterConfig.getInitParameter("allowableResourcesRoot"),
allowableResourcesRoot);
}
}
Пожалуйста, найдите страницу JSP и структуру каталогов
<link rel="shortcut icon" type="image/x-icon" href="<%=request.getContextPath()%>/images/selva/favicon.ico" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
<script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/bootstrap.js"></script>
Directory :
Src
Webcontent
css
bootstrap.css
js
bootstrap.js
WEB-INF
view
index.jsp
web.xml
Как решить эту проблему, любая помощь будет принята с благодарностью!!!!