Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7812

Allow custom request mapping conditions

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.0.5
    • Fix Version/s: 3.1 RC1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      As outlined by a user here: https://jira.springframework.org/browse/MOBILE-8, it would be useful if it was possible to map requests to @Controller methods by criteria other than path, parameter value, or header value. MOBILE-8 shrewdly suggests support for mapping by SitePreference, to allow different @Controller methods to handle requests for different versions of the application's "site", such as the "mobile" site vs. the "normal" site.

      Rather than baking in additional hard-coded mapping options, I recommend we consider adding support for mapping by boolean SpEL Expression, which can be used in conjunction with the other @RequestMapping attributes. For example:

      @RequestMapping(value="/", method=RequestMethod.GET, expression="currentSitePreference.mobile")
      public String homeMobile(Model model) {
          // prepare model needed by the mobile view
          return "home-mobile";
      }
      
      @RequestMapping(value="/", method=RequestMethod.GET)
      public String home(Model model) {
          // prepare normal model
          return "home";
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                Reporter:
                kdonald Keith Donald
                Last updater:
                Trevor Marshall
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 4 weeks, 4 days ago