Spring Framework
  1. Spring Framework
  2. SPR-5757

Externalized request mapping as a 1st class alternative alternative to @RequestMapping

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.5
    • Fix Version/s: 4.x Backlog
    • Component/s: Web
    • Labels:
    • Last commented by a User:
      true

      Description

      While I am not averse to having the controllers use annotation based configuration, I would love to see a functionally equivalent XML based routing configuration, for those who would rather not use it. The current model, IMHO, has the following problems:

      1. URL mapping is scattered all over the place. If I have 15 controllers, with 10 methods each (and note that there's the issue of each method potentially having a completely different URL that it can match), a newbie would have to look at 150 potential places to map a given URL to the controller action it resolves to. Admittedly, having good conventions and oversight will alleviate this problem, but seems too easy to have things go awry.

      2. any changes to the mapping requires a recompile.

      3. The same controller method cannot be mapped to multiple urls (or at least I can't figure out how to do it ), allowing different views to be driven by the same controller.

      4. A somewhat minor thing. There is now way to write a controller w/o Spring dependencies.

      Btw, It would be nice to have mappings that are pattern based, such as, a way to map /somepath/

      {method} to handler SomePathController, method {method}

      .

      http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/

        Issue Links

          Activity

          Hide
          Ilya Kazakevich added a comment -

          Moving it to "General backlog" means you would not implement it in 3.2 version?

          Show
          Ilya Kazakevich added a comment - Moving it to "General backlog" means you would not implement it in 3.2 version?
          Hide
          Rossen Stoyanchev added a comment - - edited

          Ilya Kazakevich, yes 3.2 will be released very soon.

          I agree with the Dennis Homann's comment the goal is externalized request mappings, be it XML or not. The springmvc-router project is one example of an alternative. The syntax is very short, which is important for 200+ controllers, and the ability to name a route from a view is very compelling.

          Also the ability to externalize or view all request mappings has been available since 3.1. It can be provided in the form of org.springframework.web.servlet.mvc.method.RequestMappingInfo from any source, not just annotations. Projects like springmvc-router and swagger-springmvc are proof of that as they build on this very mechanism.

          The question really is what form of externalized request mappings to provide explicit support for within Spring MVC. Providing an XML namespace like the one David Sledge showed is relatively trivial to create and plug in even today.

          Show
          Rossen Stoyanchev added a comment - - edited Ilya Kazakevich , yes 3.2 will be released very soon. I agree with the Dennis Homann 's comment the goal is externalized request mappings, be it XML or not. The springmvc-router project is one example of an alternative. The syntax is very short, which is important for 200+ controllers, and the ability to name a route from a view is very compelling. Also the ability to externalize or view all request mappings has been available since 3.1. It can be provided in the form of org.springframework.web.servlet.mvc.method.RequestMappingInfo from any source, not just annotations. Projects like springmvc-router and swagger-springmvc are proof of that as they build on this very mechanism. The question really is what form of externalized request mappings to provide explicit support for within Spring MVC. Providing an XML namespace like the one David Sledge showed is relatively trivial to create and plug in even today.
          Hide
          Jakub Jirutka added a comment - - edited

          Rossen Stoyanchev,

          well, if it’s so simple to provide an XML namespace config for requests mapping (that’s all what I want… and believe that also many others), why it’s not gonna be in 3.2?

          Sure, each of us can write it yourself… or write very own framework… but why? We need the only one standard namespace, from Spring. Look at Spring Security, there are many specialized namespaces and it’s great.

          I don’t think that XML is the only way either. The springmvc-router looks good, but the standard way in Spring are XML configs, aren’t they? I mean that there should be the XML namespace for that and then we can have something like springmvc-router (and annotations) as an alternative.

          As you wrote, in the case of hundreds controllers, XML is too verbose. Agree. However, in case of some tiny module where I need only few “endpoints”, I would like to have all config in one place along with beans, security etc.

          Show
          Jakub Jirutka added a comment - - edited Rossen Stoyanchev , well, if it’s so simple to provide an XML namespace config for requests mapping (that’s all what I want… and believe that also many others), why it’s not gonna be in 3.2? Sure, each of us can write it yourself… or write very own framework… but why? We need the only one standard namespace, from Spring. Look at Spring Security, there are many specialized namespaces and it’s great. I don’t think that XML is the only way either. The springmvc-router looks good, but the standard way in Spring are XML configs, aren’t they? I mean that there should be the XML namespace for that and then we can have something like springmvc-router (and annotations) as an alternative. As you wrote, in the case of hundreds controllers, XML is too verbose. Agree. However, in case of some tiny module where I need only few “endpoints”, I would like to have all config in one place along with beans, security etc.
          Hide
          Rossen Stoyanchev added a comment -

          Jakub Jirutka, point taken. It is simple in terms of we know how it can be plugged in but it would take a number of iterations to design a usable and complete XML namespace. Why is it not in 3.2? We simply didn't get to it. Just look in JIRA and Github to see the amount of work that goes on and is requested all the time. This is why we have a contribution process in place and when you really care about something, you can help move it forward.

          Show
          Rossen Stoyanchev added a comment - Jakub Jirutka , point taken. It is simple in terms of we know how it can be plugged in but it would take a number of iterations to design a usable and complete XML namespace. Why is it not in 3.2? We simply didn't get to it. Just look in JIRA and Github to see the amount of work that goes on and is requested all the time. This is why we have a contribution process in place and when you really care about something, you can help move it forward.
          Show
          Artem Bilan added a comment - Guys! Spring Integration since 3.0 provides the required solution: http://docs.spring.io/spring-integration/docs/3.0.0.BUILD-SNAPSHOT/reference/html/whats-new.html#3.0-request-mapping https://github.com/spring-projects/spring-integration/blob/master/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/Int2312RequestMappingIntegrationTests-context.xml It will be available in the upcoming Spring Integration RC1 Cheers, Artem

            People

            • Assignee:
              Rossen Stoyanchev
              Reporter:
              Vijay Natarajan
              Last updater:
              Rossen Stoyanchev
            • Votes:
              8 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                25 weeks, 2 days ago