Help designing velocity template to support Header and Footer
My websites pages are broken down into 3 parts:
- Header
- Main Content
- Footer
The header needs to access the user object to display things like the username, sign/signout links depending if the user is logged in or not.
I want my velocity templates to be like this:
inject header template, that will need access to the user object.
main content will be a spring mvc action page
footer
I know that in my spring mvc action, I will simple load my velocity template with the attr开发者_StackOverflowibutes/objects that I will need to display in the 'main content' area.
Is there a way for me to provide the 'header template' access to the attributes/objects it needs from a place OTHER than the spring mvc action?
I am new to java/spring, is there a request level collection that I can load my user object into, so I can reference it from there?
I think that the way to do this in the Spring MVC framework is to use a custom Handler Interceptor that attaches the necessary information to the request (or response) object and then returns true
to allow the request to proceed to the designated controller.
(Warning: I've never done this, YMMV, etc ...)
精彩评论