Hello, I have a task to accept a request via GET, the link is based on this template =

GET http://localhost/<url> 

Here is my controller -

 @RequestMapping(value = "/{link} ", method = RequestMethod.GET) public void addLink(@PathVariable("link") String link) { System.out.print(link); } 

If you follow the link

 http://localhost:8080/google.com 

then everything works correctly, and if you add a slash, the controller does not work

 http://localhost:8080/google.com/saa 
  • It is necessary to escape service characters. URL encode / decode methods are in any PL. - enzo

2 answers 2

The problem was solved -

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

    The controller does not work, because the link does not match the path to which it is attached.

    If you want to send a link, it is usually done with a GET request parameter:

     /saa?link='https://google.com/' 

    Why not satisfied with this option?

    • I know that this is possible, but the task was different - Jooble