1

Is there a way to get the first part of the url path, before /c:

Thats it: /Category1/Subcategory1.1/Subcategory1.1.1/c/{categoryCode:.*}

@Controller
@RequestMapping(value = "/**/c")
public class CategoryPageController {

    @RequestMapping(value = "/{categoryCode:.*}", method = RequestMethod.GET)
    public ModelAndView viewCategory(@PathVariable String categoryCode,            
            final HttpServletRequest request) {
        String categoryPath = ...

I tried to use AntPathMatcher (extractPathWithinPattern) but I'm not able to define the correct pattern.

scesnik
  • 11
  • 2

1 Answers1

0

inject the request object by simply adding the the HttpServletRequest to the method signature, and then access the Request Url by calling getRequestURL().

(oh and auto converting answers to comments, stackoverflow jumps the shark)

Community
  • 1
  • 1
NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
  • Thanks for quick reply. I've jet injected HttpServletRequest, but colling getRequestURL() i retrieve the full path (http:// ....) i don't need it, I need just the part before "/c/" for exemple: /Category1/Subcategory1.1/Subcategory1.1.1/ Regards – scesnik Jun 15 '15 at 10:45