public class SiteSwitcherRequestFilter
extends org.springframework.web.filter.OncePerRequestFilter
The initialization parameters available for configuring the servlet filter:
switcherModeserverNametabletIsMobilemobilePathtabletPathrootPathThe switcherMode init parameter requires that you specify one of three values. And for each of these
values, the corresponding additional required init params are listed.
mDotserverName is requiredtabletIsMobile is optionaldotMobiserverName is requiredtabletIsMobile is optionalurlPathmobilePath is optionaltabletPath is optionalrootPath is optionalThe following examples illustrate the different parameter configurations.
Creates a site switcher that switches between app.com and m.app.com:
<init-param>
<param-name>switcherMode</param-name>
<param-value>mDot</param-value>
<param-name>serverName</param-name>
<param-value>app.com</param-value>
</init-param>
Creates a site switcher that switches between app.com and app.mobi:
<init-param>
<param-name>switcherMode</param-name>
<param-value>dotMobi</param-value>
<param-name>serverName</param-name>
<param-value>app.com</param-value>
</init-param>
By default tablets are presented with the 'normal' site when using mDot or
dotMobi. However you can have the site switcher direct tablets to the mobile site by
setting the tabletIsMobile parameter to true.
<init-param>
<param-name>switcherMode</param-name>
<param-value>mDot</param-value>
<param-name>serverName</param-name>
<param-value>app.com</param-value>
<param-name>tabletIsMobile</param-name>
<param-value>true</param-value>
</init-param>
Creates a site switcher that switches between app.com and app.com/mob/
for mobile devices, and app.com and app.com/tab/ for tablet devices:
<init-param>
<param-name>switcherMode</param-name>
<param-value>urlPath</param-value>
<param-name>mobilePath</param-name>
<param-value>mob</param-value>
<param-name>tabletPath</param-name>
<param-value>tab</param-value>
</init-param>
| Constructor and Description |
|---|
SiteSwitcherRequestFilter() |
SiteSwitcherRequestFilter(SiteUrlFactory normalSiteUrlFactory,
SiteUrlFactory mobileSiteUrlFactory,
SiteUrlFactory tabletSiteUrlFactory,
SitePreferenceHandler sitePreferenceHandler)
Creates a new site switcher.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain) |
java.lang.String |
getMobilePath() |
java.lang.String |
getRootPath() |
java.lang.String |
getServerName() |
java.lang.String |
getSwitcherMode() |
java.lang.Boolean |
getTabletIsMobile() |
java.lang.String |
getTabletPath() |
protected void |
initFilterBean() |
void |
setMobilePath(java.lang.String mobilePath) |
void |
setRootPath(java.lang.String rootPath) |
void |
setServerName(java.lang.String serverName) |
void |
setSwitcherMode(java.lang.String switcherMode) |
void |
setTabletIsMobile(java.lang.Boolean tabletIsMobile) |
void |
setTabletPath(java.lang.String tabletPath) |
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchpublic SiteSwitcherRequestFilter()
public SiteSwitcherRequestFilter(SiteUrlFactory normalSiteUrlFactory, SiteUrlFactory mobileSiteUrlFactory, SiteUrlFactory tabletSiteUrlFactory, SitePreferenceHandler sitePreferenceHandler)
normalSiteUrlFactory - the factory for a "normal" site URL e.g. http://app.commobileSiteUrlFactory - the factory for a "mobile" site URL e.g. http://m.app.comtabletSiteUrlFactory - the factory for a "tablet" sitesitePreferenceHandler - the handler for the user site preferencepublic java.lang.String getSwitcherMode()
public void setSwitcherMode(java.lang.String switcherMode)
public java.lang.String getServerName()
public void setServerName(java.lang.String serverName)
public java.lang.Boolean getTabletIsMobile()
public void setTabletIsMobile(java.lang.Boolean tabletIsMobile)
public java.lang.String getMobilePath()
public void setMobilePath(java.lang.String mobilePath)
public java.lang.String getTabletPath()
public void setTabletPath(java.lang.String tabletPath)
public java.lang.String getRootPath()
public void setRootPath(java.lang.String rootPath)
protected void initFilterBean()
throws javax.servlet.ServletException
initFilterBean in class org.springframework.web.filter.GenericFilterBeanjavax.servlet.ServletExceptionprotected void doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
throws javax.servlet.ServletException,
java.io.IOException
doFilterInternal in class org.springframework.web.filter.OncePerRequestFilterjavax.servlet.ServletExceptionjava.io.IOException