org.springframework.web.servlet.i18n
Class AcceptHeaderLocaleResolver

java.lang.Object
  extended byorg.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
All Implemented Interfaces:
LocaleResolver

public class AcceptHeaderLocaleResolver
extends java.lang.Object
implements LocaleResolver

Implementation of LocaleResolver that simply uses the primary locale specified in the "accept-language" header of the HTTP request (i.e., the locale sent by the client browser, normally that of the client's OS).

Note: Does not support setLocale, because the accept header cannot be changed.

Since:
27.02.2003
Author:
Juergen Hoeller

Constructor Summary
AcceptHeaderLocaleResolver()
           
 
Method Summary
 java.util.Locale resolveLocale(javax.servlet.http.HttpServletRequest request)
          Resolve the current locale via the given request.
 void setLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Locale locale)
          Set the current locale to the given one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AcceptHeaderLocaleResolver

public AcceptHeaderLocaleResolver()
Method Detail

resolveLocale

public java.util.Locale resolveLocale(javax.servlet.http.HttpServletRequest request)
Description copied from interface: LocaleResolver
Resolve the current locale via the given request. Should return a default locale as fallback in any case.

Specified by:
resolveLocale in interface LocaleResolver
Parameters:
request - request to be used for resolution
Returns:
the current locale

setLocale

public void setLocale(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      java.util.Locale locale)
Description copied from interface: LocaleResolver
Set the current locale to the given one.

Specified by:
setLocale in interface LocaleResolver
Parameters:
request - request to be used for locale modification
response - response to be used for locale modification
locale - the new locale


Copyright (C) 2003-2004 The Spring Framework Project.