I am brand new to Spring web MVC. I am trying to create a simple 1 paged site that will check the users browser and display the current theme f开发者_运维知识库or that browser.
If its a mobile app, I need to allow the user a button to switch to the regular site.
Also the current theme for mobile and non-mobile is stored in a database, which includes the start date, end date and the theme name. The theme name is the folder where the theme's resources are located.
Being a beginner I have never used themeresolver.
Your help is much appreciated.
ThemeResolver is reasonably straightforward to implement.
You won't be using the setThemeName()
method, so have it throw an UnsupportedOperationException
. Your resolveThemeName()
method would:
- Get "User-Agent" request header and determine the appropriate theme.
- Run a DB query (you may want to cache this).
- Return theme name.
You'll then need to declare your implementation under 'themeResolver' name in your application context.
精彩评论