Using Spring's @RequestMapping with wildcards

This is similar to this question, but I am still confused about my situation. I want to map this ant-style pattern to a controller method:

/results/**

That is, I want any URL like www.hostname.com/MyServlet/results/123/abc/456/def/ to go to this method. I have:


    MyServlet
    /results/*

and:

@RequestMapping(value="/**", method=RequestMethod.GET)
public ModelAndView handleRequest() {...}

This works to guide the request to my method, but leads me to several questions:

  1. What if I add another servlet mapping, like /another-mapping/*??? It will also get mapped to that method! How can I separate the two?
  2. Why does the url-pattern /results/* work, whereas /results/** doesn't? According to ant path styles, ** means to include nested / characters, whereas * stops at the next /. So, it should only successfully map a URL like /results/123, bot NOT /results/123/abc/. Right?

9
задан Community 23 May 2017 в 12:34
поделиться