Announcement Announcement Module
No announcement yet.
How to have "/" backslash in @RequestMapping ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to have "/" backslash in @RequestMapping ?


    I have a requirement where the id I use in @RequestMapping accept a value of the format “1234567812345678” and “abcxyz/abcxy+z$” (basically a auto generated string with “/” forward slash in it).

    I have tried a mapping of all the 3 below formats but nothing works:

    @RequestMapping(value="abc/action/{id: .+[//]*.*}.{format}", method=RequestMethod.PUT) -- Accepts nothing.

    @RequestMapping(value=" abc/action/{id:.+}.{format}", method=RequestMethod.PUT) -- Accepts everything except ‘/’

    @RequestMapping(value=" abc/action/{id:.*}.{format}", method=RequestMethod.PUT) -- Accepts everything except ‘/’

    However, when I try the same regex in a normal java program, it works like a charm :

    package miscellenousTest;
    public class RegExTest {
    public static void main(String[] args) {
    String s1 ="9876543298765432";
    String s2 =" abcxyz/abcxy+z$";

    I have gone through some of the previous posts but nothing gives me the exact solution I am looking for.

    It will be great if someone can throw some pointers/solution at this one.
    Last edited by deepinjava; Apr 28th, 2012, 11:26 PM.