Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>@ModelAttribute</code> method annotation is intended to be used for <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-modelattrib" rel="noreferrer">exposing reference data</a> to the view layer. I can't say for sure in your case, but I wouldn't say that a collection of users qualified as reference data. I suggest that you pass this information through to the model explicitly in your <code>@RequestMapping</code>-annotated handler methods.</p> <p>If you still want to use <code>@ModelAttribute</code>, there's a <a href="http://developingdeveloper.wordpress.com/2008/02/28/common-reference-data-in-spring-mvc/" rel="noreferrer">blog</a> entry here that discusses the redirect problem.</p> <blockquote> <p>But all the previous examples have a common issue, as all @ModelAttribute methods are run before the handler is executed, if the handler returns a redirect the model data will be added to the url as a query string. This should be avoided at all costs as it could expose some secrets on how you have put together your application.</p> </blockquote> <p>His suggested solution (see part 4 of the blog) is to use a <a href="http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html#mvc-handlermapping-interceptor" rel="noreferrer"><code>HandlerInterceptorAdapter</code></a> to make the common reference data visible to the view. Since reference data shouldn't be tightly coupled to the controllers, this shouldn't pose a problem, design-wise. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload