Chaining Spring CookieLocaleResolver and AcceptHeaderLocaleResolver

I want to resolve the user's locale first by detecting a cookie, and if there isn't one then by the accept-language header. Spring seems to only want to accept a single LocaleResolver.

Interestingly, the spring docs for CookieLocaleResolver state

LocaleResolver implementation that uses a cookie sent back to the user in case of a custom setting, with a fallback to the specified default locale or the request's accept-header locale.

but this doesn't actually seem to be the case; testing shows it doesn't work and a quick look at the source shows it only gets the default if there is no cookie.

Is the only solution to write my own LocaleResolver implementation?


It looks like CookieLocaleResolver do exactly what you want as long as you don't set its defaultLocale.

If you want something different (for example, fallback to defaultLocale when neither cookie nor Accept header was found), you can override its determineDefaultLocale() accordingly.

Need Your Help

MVC SelectList Drop down default


In the SelectList drop down, I like if the Count is 1, I like to default the value of what is there in the drugfamilylist which in this case is just 1 value. I cannot figure out how to do this.

MS Visual Studio 2010: _UzpVersion is requested by object file, but _UzpVersion@0 is exported by library

c++ visual-studio-2010 name-mangling

I'm trying to build my project using MS Visual Studio 2010 with the Info-ZIP unzip library. When I inserted UzpVersion() call into the code, the linker failed saying:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.