views:

26

answers:

1

Greetings all...

I have a simple, yet annoying question regarding Spring Web MVC.

I come from about 7 years of Struts development and have gotten used to all of the ins-and-outs that come with Struts, however, I've decided to take the plunge into using Spring MVC and so far I love what I see.

One thing that I cannot seem to figure out is how to pass a message back to the client (the .jsp) from the controller. If it were struts I would use the ActionMessages class and the html:messages tag, however, I cannot find the same sort of construct in Spring MVC. Is this sort of thing done a different way or am I just totally blind? I've spent the better part of a day trying to get a grip on it.

I guess I could put the message just in the request or bind it to the model; I just didn't know if there was a better way of doing it.

Thanks.

+1  A: 

Can you explain what you mean by a "message"?

In Spring MVC the controller can only return a Model and a View (in the ModelAndView class).

Any "data" needed for rendering the view should be added to the Model.

It's perfectly acceptable to put data into the Model that isn't necessarily something you intend to display to the end-user but rather to be used in rendering the view, i.e. a flag like "firstLogin" to display one block of text versus another, etc.

matt b
Thanks, I think that's exactly the answer I was looking for.
El Guapo