Thursday, June 23, 2011

mvc:view-controller

This tag is a shortcut for defining a ParameterizableViewController that immediately forwards to a view when invoked. Use it in static cases when there is no Java Controller logic to execute before the view generates the response.

An example of view-controller that forwards to a home page is shown below:
Source: http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html

Tuesday, June 21, 2011

Spring 3.1 M2: Spring MVC Enhancements

Programming Model Improvements

This is the list of programming model improvements introduced in the new @MVC support classes.
  1. Declared @PathVariable arguments are now automatically added to the model. For example this:

  2. is replaced by:


  3. Redirect strings support URI templates expanded with variables from the model (including declared @PathVariables). For example this:

  4. is replaced by:


  5. URI template variables are supported in data binding. For example this:

  6. is replaced by:


  7. Consumable and producible media types can be specified via @RequestMapping. For example this:

  8. is replaced by:

    Besides being shorter the above returns NOT_ACCEPTABLE (406) if the URL matches but the input media type doesn't.

  9. For producible media types this:

  10. is replaced by:

    The above returns a NOT_SUPPORTED_MEDIA_TYPE (415) if the URL matches but the acceptable media type doesn't.