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:

  1. In the Spring configuration class, declare a DeviceResolverHandlerInterceptor bean and a SitePreferenceHandlerInterceptor bean and register them as interceptors:
    @Bean
    public DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor() { return new DeviceResolverHandlerInterceptor(); } @Bean public ...

Get Spring Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.