作者TonyQ (骨頭)
看板java
標題Re: [問題]JSP如何解決顯示網頁已經過期問題
時間Sat May 17 23:06:11 2008
※ 引述《kucom (kucom)》之銘言:
: 我做二個jsp網頁 info.jsp及detail.jsp
: 當我點info.jsp裡的某個欄位即可連結至detail.jsp 看該欄位的詳細資料
: 現在問題是:當我連結至detail.jsp時,我欲返回info.jsp
: 網頁則顯示:"網頁已經過期...balabala..."
: 這樣很困擾 也不合理
: 因為這樣我每次看完detail.jsp,欲再看其他資料時,就必須重新查詢
: 我有在info.jsp及detail.jsp加下列的code,但仍會有網頁已經過期的問題
: if ( request.getProtocol().compareTo("HTTP/1.0")==0)
: response.setHeader("Pragma","no-cache");
: else if ( request.getProtocol().compareTo("HTTP/1.1")==0)
: response.setHeader("Cache-Control" , "no-cache");
: response.setDateHeader("Expires",0);
: 有版友有這樣的問題嗎? 該如何解決?
: 感謝感謝~~~
這個是expire的時間已到
這個tag的意義參考一下這網頁
http://www.i18nguy.com/markup/metatags.html
The date and time after which the document should be considered expired. An
illegal EXPIRES date, e.g.
"0", is interpreted as "now". Setting EXPIRES to 0
may thus be used to force a modification check at each visit.
Web robots may delete expired documents from a search engine, or schedule a
revisit.
簡單來說expire這個header是設定到期的時間的,
假設設定0就表示閱讀的那一刻就到期了,按上一頁就會出現網頁資訊已過期。
解決方法應該是把
response.setDateHeader("Expires",0);
給註解掉
這個expire主要是用在避免表單重複填寫/送出用的,
另外也是避免有心人透過上一頁去試著瀏覽機密資訊(如密碼等)的措施。
--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.27.68
推 ecbytesan:YA 05/18 19:23
推 kucom:謝謝TONY大...但我今天把它MARK起來RUN,仍顯示網頁過期>"< 05/22 22:25