使用WebSphere Portal开发多区域设置网站
2010-09-27 08:17:29 来源:WEB开发网接下来,请求包装需要重写 getHeader 和 getHeaders 方法,以便能在指定的键为 Accept-Languag 时返回 Servlet 筛选器指定的区域设置。
清单 2. LocaleRequestWrapper getHeader() 和 getHeaders() 方法
public String getHeader(String key)
{
// get the original request
HttpServletRequest request = (HttpServletRequest)getRequest();
// if the header request is for locale, return the stored locale
if ("Accept-Language".equalsIgnoreCase(key))
{
if (locale != null) return locale;
// if no locale is set, then return a value that would cause
// WPS to use default language.
else return request.getHeader(key);
}
// if the requested header is not the locale, return the value
// from the wrapped request
else
return request.getHeader(key);
}
public Enumeration getHeaders(String key)
{
// get the original request
HttpServletRequest request = (HttpServletRequest)getRequest();
// if the header request is for locale, return the stored locale
if ("Accept-Language".equalsIgnoreCase(key))
{
if (locale != null) return Collections.enumeration(locales);
// if no locale is set, then return a value that would cause
// WPS to use default language.
else return request.getHeaders(key);
}
// if the requested header is not the locale, return the value
// from the wrapped request
else
return request.getHeaders(key);
}
编缉推荐阅读以下文章
- 扩展WebSphere Portal V6个性化功能
更多精彩
赞助商链接