Skip to content

Add mvc namespace element for registering Parameterizable View Controllers [SPR-6413] #11079

Closed
@spring-projects-issues

Description

@spring-projects-issues

Keith Donald opened SPR-6413 and commented

Spring Roo has the requirement to map a web requests to static views. Rather than configure a "default handler" that attempts to map any request not handled by a Controller to a view, they're now defining a ParameterizableViewController bean for each static view [which is a safer and more explicit]. This change results in some extra low-level bean configuration that could be simplified.

Currently, the following must be added to mvc-config.xml:

<!-- Required to enable invocation of org.springframework.web.servlet.Controllers -->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
<!-- Required for bean name-based request mapping -->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" p:order ="1">
    <!-- Register any interceptors, typically duplicating interceptor set with other handler mappings -->
    <property name="interceptors"> ... </property>
</bean>
<!-- Required for each static view controller -->
<bean name="/index" class="org.springframework.web.servlet.mvc.ParameterizableViewController" p:viewName="index" />

Proposal:

  • We can simplify the above config by encapsulating the registration of the SimpleControllerHandlerAdapter and BeanNameUrlHandlerMapping beans in the mvc:annotation-driven element.
  • We can simplify the registration of ParameterizableViewControllers by introducing a custom mvc namespace tag such as:
<mvc:view-controller path="/index" /> <!-- defaults to view name "index" via RequestToViewNameTranslator -->

<mvc:view-controller path="/foo" view-name="aCustomViewName" />

Affects: 3.0 RC2

Issue Links:

  • ROO-385 Use new Spring MVC namespace ("is depended on by")

Referenced from: commits de1d548

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions