0

In my application I delete image by passing image id to REST api like this.

DELETE http://localhost:8080/connect/images/123456/abcdef

So, I mapped this with spring MVC as follows

@ResponseBody
    @RequestMapping(value="/images/{imageId}", method=RequestMethod.DELETE,
    produces=MediaType.APPLICATION_JSON_VALUE)
    public ResponseObject deleteImage(final HttpServletResponse response, HttpServletRequest request,   @PathVariable("imageId") final String imageId) {
        return ResponseUtil.executeInTryCatch(new ResponseCallback() {
            @Override
            public Object execute() throws Throwable {
                deleteImage(imageId);
                return "Image deleted successfully";
            }
        });
    }

But I am not able to fetch rest of URI after images to imageId path variable. I want imageId should be 123456/abcdef. Is there a way to extract using @PathVariable regular expression support?

Pokuri
  • 3,072
  • 8
  • 31
  • 55
  • But that solution doesn't work. I am still getting 404 – Pokuri Oct 05 '16 at 09:11
  • 1
    The first answer does work. You cannot bind a part of the URI into a `@PathVariable` that contains a slash as it's a fully-reversed character in URI schemas (and file system paths/names). You need to either extract the identifier you need manually from `@RequestMapping("/images/**")` or, fix your implementation and stop sending slashes as part of an identifier - it's a stupid solution. – rorschach Oct 05 '16 at 09:33

0 Answers0