Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Nov 23, 2009 · 1 comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Keith Donald commented

When you have custom handler interceptors registered using the mvc:interceptors sub element of the mvc:annotation-driven element, you'd have to also duplicate registration of those interceptors for the BeanNameUrlHandlerMapping as well. This is not ideal - the mvc:annotation-driven element should really encapsulate the registration of both handler mappings and the setup of the interceptor set for each.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 RC3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant