我正在使用 struts.serve.static=true
和 struts.serve.static.browserCache=false
,但即使在注销后后退按钮也可以使用.当我单击后退按钮时,它将转到上一个屏幕.我该如何解决这个问题?
I am using struts.serve.static=true
and struts.serve.static.browserCache=false
, but the back button is working even after logout. When i click on the back button it is going to the previous screen. How do i solve this issue?
上面的常量会被 S2 用来告诉浏览器是否需要缓存静态内容.
The above constants will be used by S2 to tell browser if they need to cache static content.
struts.serve.static=true
FilterDispatcher
struts.serve.static.browserCache=true
也被 FilterDispatcher
使用,并且只有在 struts.serve.static=true
时才有效.
also struts.serve.static.browserCache=true
is used by FilterDispatcher
and will work only if struts.serve.static=true
.
关于浏览器后退按钮,我们不能将浏览器后退按钮作为浏览器 API 的一部分禁用,并且当您点击后退按钮时,浏览器会从其缓存中提供内容而无需访问服务器.
Regarding browser back button we can not disable browser back button as its a part of Browser API and when you are hitting the back button browser is serving the content from its cache without hitting the server.
您可以通过使用缓存控制标头来要求浏览器不要缓存内容,但浏览器是否尊重它们.在您的 JSP 中使用以下代码
You can ask the browser not to cache the content by using cache control header but its upon the browser to respect them or not. use following code in your JSP
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
或者,您可以创建一个拦截器并使用所需的操作对其进行配置,以便可以设置标头.有关如何控制 S2 中的缓存的更多详细信息,请参阅以下线程
Alternatively you can create an Interceptor and configure it with your desired action so that the headers can be set. Please go through the following thread for more details as how to control the cache in S2
这篇关于如何使用 Struts2 禁用后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!