views:

44

answers:

1

My websites pages are broken down into 3 parts:

  1. Header
  2. Main Content
  3. 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 attributes/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?

+1  A: 

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 ...)

Stephen C