situation:I have an application that uses separate jsp files for each specific country(I've implemented with view resolver). However with this approach I have to repeat the jsp changes for each country even if there is no specific change for that page.
example: for users of "en" theme I have different invoice page than users of "de" theme with different layout and different logic. Goes to same controller and has different actions according to user. but most of the time the logic and the jsp page is same (for example listing of accounts). quest开发者_开发技巧ion:How can keep this logic and also make a fallback page for that specific action? If exists /de/invoice.jsp just use this else use /invoice.jsp(just like the themes in drupal) I use tomcat as application server. Any suggestion?(Please note that by "theme" I do not mean Spring's support for themes, but rather the general problem can be solved with Spring's themes.)
Basically you just want to pick the page of a <jsp:include>
dynamically.
Let's assume that you put the page name to include in a variable called "invoicePage". Then, the page template that's referenced in your view resolver can include that variable as follows:
<jsp:include page="${invoicePage}"/>
So, the only trick is picking the right invoicePage.
Spring themes have a nice solution to this: put the name of the theme-specific include in your theme-specific properties file, and Spring will take care of falling back to the default for you.
Alternatively you can implement your own, probably based on a configuration that either lists countries with specific content or that sets an indicator on a per country basis. Which solution is appropriate depends on how you've configured the rest of your app.
精彩评论