Switching to the normal view on mobiles
A mobile user gets the mobile version of the website by default, but he/she may want to access some contents displayed only on the normal version. Spring Mobile offers the SitePreference
object for that purpose, which is to be used instead of the Device
object used in the previous recipe.
How to do it…
Follow these steps to create links, to switch between the normal version and the mobile version of a website:
In the Spring configuration class, declare a
DeviceResolverHandlerInterceptor
bean and aSitePreferenceHandlerInterceptor
bean and register them as interceptors:@Bean public DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor() { return new DeviceResolverHandlerInterceptor(); } @Bean public SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor() { return new SitePreferenceHandlerInterceptor(); } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(deviceResolverHandlerInterceptor...