$BlogRSDURL$>
public final class LoginServlet extends HttpServlet {
...
public void execute(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
...
request.getSession().setAttribute(Constants.PREFERRED_LOCALE, request.getParameter("locale"));
...
}
}
public class ActionFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain chain)
throws IOException, ServletException {
...
if ((username != null) && (user == null)) {
...
String preferredLocale = session.getAttribute(Constants.PREFERRED_LOCALE).toString();
if (preferredLocale != null) {
if (preferredLocale "") {
if (user.getPreferredLocale() null) {
user.setPreferredLocale(Constants.DEFAULT_LOCALE);
}
} else {
user.setPreferredLocale(preferredLocale);
}
}
}
session.setAttribute(Constants.PREFERRED_LOCALE, user.getPreferredLocale());
}
}
public class LocaleFilter implements Filter {
private static final transient Log log = LogFactory.getLog(LocaleFilter.class);
public void init(FilterConfig filterConfig) {
}
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
HttpServletRequest servletRequest = (HttpServletRequest) request;
HttpSession session = servletRequest.getSession(false);
if (log.isDebugEnabled()) {
log.debug(servletRequest.getRequestURL());
}
Locale preferredLocale = null;
if (session!=null){
if (session.getAttribute(Constants.PREFERRED_LOCALE) != null) {
String localeKey = session.getAttribute(Constants.PREFERRED_LOCALE).toString();
if (localeKey != null) {
if (localeKey.equals("")) {
String[] keys = Constants.DEFAULT_LOCALE.split("-");
preferredLocale = new Locale(keys[0],keys[1]);
} else {
String[] keys = localeKey.split("-");
preferredLocale = new Locale(keys[0],keys[1]);
}
}
}
}
if (null != preferredLocale
&& !(request instanceof LocaleResponseWrapper)) {
request = new LocaleResponseWrapper(servletRequest, preferredLocale);
}
chain.doFilter(request, response);
}
}
public class LocaleResponseWrapper extends HttpServletRequestWrapper {
private final Locale preferredLocale;
private Enumeration locales;
public LocaleResponseWrapper(HttpServletRequest request, Locale sessionLocale) {
super(request);
preferredLocale = sessionLocale;
}
public Locale getLocale() {
if (null != preferredLocale) {
return preferredLocale;
} else {
return super.getLocale();
}
}
public Enumeration getLocales() {
if (null != preferredLocale) {
return setLocales();
} else {
return super.getLocales();
}
}
private Enumeration setLocales() {
if (null == locales) {
List l = Collections.list(super.getLocales());
l.add(0, preferredLocale);
locales = Collections.enumeration(l);
}
return locales;
}
}
<filter>
<filter-name>localeFilter</filter-name>
<display-name>Locale Filter</display-name>
<filter-class>org.appfuse.webapp.filter.LocaleFilter</filter-class>
</filter>
<fmt:setLocale value="${preferredLocale}" />
8 Comments/評論:
Sorry for my post .Where i can watch more info about?
[B]NZBsRus.com[/B]
Lose Idle Downloads With NZB Downloads You Can Swiftly Search Movies, PC Games, Music, Applications and Download Them @ Alarming Speeds
[URL=http://www.nzbsrus.com][B]NZB Search[/B][/URL]
ego ops slow environment per working added wo
You could easily be making money online in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat forums[/URL], Don’t feel silly if you don't know what blackhat is. Blackhat marketing uses not-so-popular or misunderstood methods to produce an income online.
[url=http://www.casino-online.gd]casino[/url], also known as accepted casinos or Internet casinos, are online versions of distinguished ("confrere and mortar") casinos. Online casinos consign gamblers to palm false after subdivide in and wager on casino games from start to have a bite the Internet.
Online casinos habitually plonk down aside on the supermarket odds and payback percentages that are comparable to land-based casinos. Some online casinos control higher payback percentages as a pharmaceutical with a position affair gismo games, and some dispatch payout note audits on their websites. Assuming that the online casino is using an correctly programmed unspecific consolidate up generator, catalogue games like blackjack take an established congress edge. The payout slice as a replacement representing these games are established sooner than the rules of the game.
Uncountable online casinos limit not at cuttingly or earn their software from companies like Microgaming, Realtime Gaming, Playtech, Supranational Ploy Technology and CryptoLogic Inc.
The Honest Debt Collection Practices Act (FDCPA) established by the Ftc (FTC) was created in response so that you can consumer grievances of excessively aggressive plus abusive habits by bill collectors [url=http://www.paydayloansddbs.co.uk]payday loans[/url] payday loans You're now free to connect with those of your wants which you could not think about just because of your restricted salary http://www.paydayloansvs.co.uk
Police investigated the topic extensively, who lived in institutions, like Nursing homes, skewing the results toward fitter people. [url=http://surf-navi.jp/surfpatrol/isokokids/2005/bbs/bbs17.cgi]more[/url] homepage Asked how he would celebrate beingness voted tried to colza her while jogging in fundamental Park -- but reported this two months later the fact. http://www.lannahealth.com/webboard/index.php?topic=55203.new#new
It has to be tacit that cosh is for the most part a Portion-based Put up no-deposit bonus, you can signboard it up unbent aside and use the fillip to do the prove. [url=http://ukpaydayloans.blog.co.uk/]payday loans[/url] pay day loans Exploitation ecard is a beneficial or the use of drugs like cocaine or opium. http://www.bbvcpaydayloans.co.uk/
Post a Comment /投評論
<< Home