2

I have a Spring-MVC project which needs to have 2 views for example: views/xxx/... views/yyy/..., I wondering how to determine which view i gonna use based on the domains for example: xxxcom, yyycom.

I know how to make one InternalResourceViewResolver,

but no clues for the multiple views based on the domains.

Eric J.
  • 147,927
  • 63
  • 340
  • 553
user809355
  • 55
  • 1
  • 5

1 Answers1

1

Depending on your specific problem, rather than using different views based upon the domain I would go with Spring's Theme resolver to use the same views then change different parts of that view based upon the domain.

You can then swap out different bits of styling and content based upon the domain being visited.

For more information on the Spring theme resolver:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-themeresolver

After understanding the way to implement themes you would simply have to write a theme resolver that resolved the theme properties file based upon the domain the user has visited.

Of course if you need completely different views for the different domains you might need a slightly different solution.

eggsy84
  • 1,059
  • 1
  • 14
  • 26
  • they are different views, so do you know a better solution? – user809355 Aug 15 '11 at 22:27
  • Unfortunately I'm not sure of a way in Spring that you can do (that doesn't mean that one doesn't exist). However, if I were to implement it I would probably go down an AOP line and develop an aspect that is identified by an annotation which you place above all your controller methods. Then when the pointcut is triggered I would switch out the view based upon the domain. How – eggsy84 Aug 16 '11 at 13:52