Добавьте заголовок Expires или Cache-Control в JSP

Ни одно из выпущенных решений не работает, когда вам нужно, чтобы нижний div прокручивался, когда содержимое слишком высокое. Вот решение, которое работает в этом случае:

HTML:

This is the header whose height is unknown
This is the header whose height is unknown
This is the header whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown
This is the scrollable content whose height is unknown

CSS:

.table {
  display: table;
}
.table-row {
  display: table-row;
}
.table-cell {
  display: table-cell;
}
.container {
  width: 400px;
  height: 300px;
}
.header {
  background: cyan;
}
.body {
  background: yellow;
  height: 100%;
}
.body-content-outer-wrapper {
  height: 100%;
}
.body-content-inner-wrapper {
  height: 100%;
  position: relative;
  overflow: auto;
}
.body-content {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

Исходный источник: заполнение оставшейся высоты контейнера при обработке переполнения в CSS

Предварительный просмотр в реальном времени JSFiddle

29
задан BartoszKP 23 January 2014 в 20:40
поделиться

2 ответа

Чтобы отключить кеш браузера для страниц JSP, создайте фильтр , который сопоставлен с шаблоном URL из *. Jsp и в основном выполняет следующие действия в метод doFilter () :

HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
httpResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0
httpResponse.setDateHeader("Expires", 0); // Proxies.

Таким образом, вам не нужно копировать это на все страницы JSP и загромождать их скриптлетами .

Чтобы включить кеширование браузера для статических компонентов, таких как CSS и JS, поместите их все в общую папку, например / static или / resources , и создайте фильтр который отображается на URL-шаблоне из / static / * или / resources / * и в основном выполняет следующие действия в doFilter () метод:

httpResponse.setDateHeader("Expires", System.currentTimeMillis() + 604800000L); // 1 week in future.

См. Также:

71
ответ дан 28 November 2019 в 00:51
поделиться
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
%>
10
ответ дан 28 November 2019 в 00:51
поделиться
Другие вопросы по тегам:

Похожие вопросы: