??????? 将HTTP响应头信息中的缓存参数设置为不进行缓存。
??????? 在 java web 项目的 web.xml 文件中添加如下代码。
class="xml comments" style="background: none !important; margin: 0px !important; padding: 0px !important; border-radius: 0px !important; border-image: none !important; width: auto !important; height: auto !important; text-align: left !important; color: #008200 !important; line-height: 1.8em !important; overflow: visible !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 12px !important; font-style: normal !important; font-weight: normal !important; vertical-align: baseline !important; float: none !important; white-space: pre-wrap;"><!--设置不使用缓存的过滤器配置? 开始 -->
<
filter
>
?
<
filter-name
>ClearCacheFilter</
filter-name
>
?
<
filter-class
>com.hmw.filter.ClearCacheFilter</
filter-class
>
</
filter
>
?
<
filter-mapping
>
?
<
filter-name
>ClearCacheFilter</
filter-name
>
?
<
url-pattern
>*.do</
url-pattern
>
</
filter-mapping
>
<
filter-mapping
>
?
<
filter-name
>ClearCacheFilter</
filter-name
>
?
<
url-pattern
>*.jsp</
url-pattern
>
</
filter-mapping
>
<!--设置不使用缓存的过滤器配置? 结束 -->
package
?com.hmw.filter;
?
import
?java.io.IOException;
?
import
?javax.servlet.Filter;
import
?javax.servlet.FilterChain;
import
?javax.servlet.FilterConfig;
import
?javax.servlet.ServletException;
import
?javax.servlet.ServletRequest;
import
?javax.servlet.ServletResponse;
import
?javax.servlet.http.HttpServletResponse;
?
/**
?
* 使浏览器不缓存页面信息的过滤器<br>
?
*/
public
?class
?ClearCacheFilter
implements
?Filter {
?
????
@Override
????
public
?void
?init(FilterConfig filterConfig)
throws
?ServletException {
????
}
?
????
@Override
????
public
?void
?doFilter(ServletRequest request, ServletResponse response,
????????????
FilterChain filterChain)
throws
?IOException, ServletException {
????????
HttpServletResponse httpResponse = (HttpServletResponse) response;
????????
httpResponse.setHeader(
"Cache-Control"
,
"no-cache"
);
????????
httpResponse.setHeader(
"Pragma"
,
"no-cache"
);
????????
httpResponse.setDateHeader(
"Expires"
, -
1
);
????????
filterChain.doFilter(request, response);
????
}
?
????
@Override
????
public
?void
?destroy() {
????
}
}
?