Wicket 6.x或7.x中的configureResponse()
我在wicket 1.4.9中使用了以下配置响应()Wicket 6.x或7.x中的configureResponse(),wicket,wicket-1.5,wicket-6,wicket-1.6,wicket-7,Wicket,Wicket 1.5,Wicket 6,Wicket 1.6,Wicket 7,我在wicket 1.4.9中使用了以下配置响应() protected void configureResponse() { super.configureResponse(); WebResponse response = getWebRequestCycle().getWebResponse(); response.setHeader("Cache-Control", "no-cache, max-age=0,must-revalidate,
protected void configureResponse() {
super.configureResponse();
WebResponse response = getWebRequestCycle().getWebResponse();
response.setHeader("Cache-Control", "no-cache, max-age=0,must-revalidate, no-store");
response.setHeader("Expires", "-1");
response.setHeader("Pragma", "no-cache");
response.setCharacterEncoding("text/html; charset=utf-8");
response.setLocale(new Locale(Constants.USER_LANG_PREF_ENG));
}
所以现在在wicket 6中,configureResponse()被删除,并被configureResponse(WebResponse response)替换,所以我尝试使用如下所示的方法编写上述代码
@Override
protected void configureResponse(WebResponse response) {
// TODO Auto-generated method stub
super.configureResponse(response);
response.setHeader("Cache-Control", "no-cache, max-age=0,must-revalidate, no-store");
response.setHeader("Expires", "-1");
response.setHeader("Pragma", "no-cache");
final String encoding = "text/html" + getMarkupType() + "; charset=utf-8";
response.setContentType(encoding);
final Locale originalLocale = getSession().getLocale();
getSession().setLocale(new Locale(Constants.USER_LANG_PREF_ENG));
}
有人能告诉我,这段代码将与前一段代码一样工作,或者我需要再次修改吗?这几乎是一样的,但你并不真正需要它,因为Wicket无论如何都会为你做这件事 检查
super.configureResponse(响应)的实现情况
和org.apache.wicket.markup.html.WebPage#setHeaders(WebResponse)
除此之外:
- 最终语言环境originalLocale=getSession().getLocale();-<代码>原始比例未使用
- getSession().setLocale(新区域设置(Constants.USER_LANG_PREF_ENG));-这可能应该移动到
YourApplication#newSession()
((HttpServletResponse)webResponse.getContainerResponse()).setLocale(…)
嗨,Martin,您能给出解决此问题的方法吗