Announcement Announcement Module
Collapse
No announcement yet.
A dot (".") in @RequestMapping value Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • A dot (".") in @RequestMapping value

    Hi,

    I need to use a dot in my RequestMapping :
    Code:
    @Controller
    @RequestMapping(value = "/test/1.0")
    public class TestController {
    
        @RequestMapping(value = "/helloWorld", method = RequestMethod.GET)    
        public ModelAndView helloWorld() {
            return new ModelAndView("test", "message", "Hello, World!");
        }
        
    }
    In
    Code:
    org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.determineUrlsForHandler(String)
    an AntPathMatcher is used to combine typeLevelPattern with methodLevelPattern
    Code:
    org.springframework.util.AntPathMatcher.combine(String, String)
    but the dot in @RequestMapping(value = "/test/1.0") prevents to simply concatenate "/test/1.0" with "/helloWorld".

    What can I do to make this work ?

    Thanks in advance.

  • #2
    You might want to try something like this. Use a path variable to determine what actions need to happen based on the pathValue.

    Check here for more details:
    http://static.springsource.org/sprin...pping-advanced

    Code:
    @Controller
    @RequestMapping(value = "/test")
    public class TestController {
    
        @RequestMapping(value = "/{pathValue}", method = RequestMethod.GET)    
        public ModelAndView helloWorld(@PathVariable String pathValue) {
    
            if(pathValue.equals("1.0")) {
                return new ModelAndView("test", "message", "Hello, World!");
            } else {
                //do something else
            }
        }
        
    }

    Comment

    Working...
    X