开发者

How to load themes from a database in Spring MVC based on user-agent , etc

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:

  1. Get "User-Agent" request header and determine the appropriate theme.
  2. Run a DB query (you may want to cache this).
  3. Return theme name.

You'll then need to declare your implementation under 'themeResolver' name in your application context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜