Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SpringMVC3.1:防止JSP缓存在浏览器中_Jsp_Caching_Spring Mvc_Browser Cache - Fatal编程技术网

SpringMVC3.1:防止JSP缓存在浏览器中

SpringMVC3.1:防止JSP缓存在浏览器中,jsp,caching,spring-mvc,browser-cache,Jsp,Caching,Spring Mvc,Browser Cache,我的网络应用程序使用Spring3.1。我试图阻止一个JSP被缓存在用户的浏览器中,以防止他们通过返回按钮访问它 我很幸运在打印HTML页面的servlet中使用了这些设置: response.setHeader("Cache-control", "no-cache, no-store"); response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "-1");

我的网络应用程序使用Spring3.1。我试图阻止一个JSP被缓存在用户的浏览器中,以防止他们通过返回按钮访问它

我很幸运在打印HTML页面的servlet中使用了这些设置:

response.setHeader("Cache-control", "no-cache, no-store");
response.setHeader("Pragma", "no-cache");                
response.setHeader("Expires", "-1");                     
我无法让这些调用在控制器函数中工作(通常从重定向调用):

我还尝试像这样将调用放入JSP中(在头文件的include上方和下方):


我还尝试将调用放在每个JSP中包含的头文件中,尽管我只希望不存储一个JSP…只是想看看是否可以让它工作。它不起作用:

<%@ page language = "java" session = "true" import = "java.util.*, java.text.*" %>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix = "f" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

<title>Acme Customer Service</title>
    <link rel = "StyleSheet"  href = "../nsd/css/nsd.css"   type = "text/css"/>
</head>

Acme客户服务
我还尝试在0和-1之间切换“Expires”设置。没有骰子

关于如何将单个JSP缓存到用户浏览器中,有什么想法吗

非常感谢


Steve

使url每次都是唯一的:向url添加get参数以包含历元秒或其他唯一字符串


因此,您将得到如下结果:

使url每次都是唯一的:向url添加get参数以包含历元秒或其他唯一字符串


因此,您将得到如下结果:

您将要扩展,如果请求的uri与控制器的uri匹配,则在postHandle方法中添加头。您还可以在控制器的HttpServletRequest中设置一个属性,然后在拦截器中检查它。您还可以使用为给定uri创建拦截器。

您需要扩展,如果请求的uri与控制器的uri匹配,则在postHandle方法中添加标头。您还可以在控制器的HttpServletRequest中设置一个属性,然后在拦截器中检查它。您还可以使用为给定uri创建拦截器。

我对Spring有点陌生。你能举个例子吗?Spring是否会以正常方式覆盖我使页面过期的能力?我对Spring有点陌生。你能举个例子吗?Spring是否以正常方式覆盖了我使页面过期的能力?
<%@ include file="header.jsp" %>
<%
   response.setHeader("Cache-control", "no-cache, no-store");
   response.setHeader("Pragma", "no-cache");                
   response.setHeader("Expires", "-1"); 
 %>
     <!-- content -->

<%@ include file="footer.jsp" %>
<%@ page language = "java" session = "true" import = "java.util.*, java.text.*" %>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix = "f" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

<title>Acme Customer Service</title>
    <link rel = "StyleSheet"  href = "../nsd/css/nsd.css"   type = "text/css"/>
</head>