我在付費角色系統上工作,一旦用戶刷新瀏覽器,我需要刷新該頁面中可用的統計數據(統計數據應該從數據庫中獲取並顯示)。但是現在它不能正常工作,因爲在頁面刷新中,java代碼沒有被調用,而是使用先前的數據加載緩存頁面。 我試着修復它添加下面的代碼,但它沒有工作。在瀏覽器刷新中刷新導覽面板
@Override
protected void setHeaders(WebResponse response) {
response.setHeader("Cache-Control",
"no-cache, max-age=0,must-revalidate, no-store");
}
任何人都知道這個問題的解決方法? 謝謝!
這是最初的代碼
ManageCredits.html
<wicket:head>
<wicket:link>
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
</wicket:link>
</wicket:head>
<wicket:panel xmlns:wicket="http://wicket.apache.org/">
<div class="offercount-container round-border">
<div class="manage-credits-lbl"><span>Manage Credits</span></div>
<div>
<ul>
<li>Balance amout:<span wicket:id="balanceAmtLbl" >0</span></li>
<li>Number if transactions<span wicket:id="transactionLbl" >0</span></li>
</ul>
</div>
</div>
</wicket:panel>
ManageCredits.java
import com.payrole.service.Offer;
import com.payrole.service.OfferService;
import com.payrole.service.ServiceLocator;
import com.payrole.wicket.PayroleLabel;
import java.text.Format;`enter code here`
import org.apache.wicket.markup.html.panel.Panel;
public class OfferFanSummaryPanel extends Panel{
private long balance;
private long transactionCount;
public OfferFanSummaryPanel(String id){
super(id);
}
public OfferFanSummaryPanel(String id, Offer offer) {
super(id);
balance = (client.getBalance()==null) ? 0 : client.getBalance();
transactionCount = (client.getTransactionCount()==null) ? 0 : client.getTransactionCount();
initTransactionSummary();
}
private void initTransactionSummary(){
PayroleLabel balanceAmtLbl = new PayroleLabel("balanceAmtLbl", String.valueOf(balanceAmt), PayroleLabel.NUMBER);
add(balanceAmtLbl);
PayroleLabel transactionLbl = new PayroleLabel("transactionLbl", String.valueOf(transaction), PayroleLabel.NUMBER);
add(transactionLbl);
}
}
非常感謝您的答覆,但它不是我真的不清楚。所以我添加了一段代碼。 – user1266343 2012-04-09 00:37:26
@ user1266343我更新了我的答案 – bert 2012-04-09 13:41:01
我試過這種方式,但它仍然不會在頁面更新中更新:( – user1266343 2012-04-10 07:36:56