Reputation: 937
I have a web application written on Spring 3.1 (not boot) and running on Tomcat 7.
I have a @Controller implements method PUT on a certain URL. In some cases When sending a PUT request from Postman, I get a 403 response instead of what is expected.
For example:
I also implement a filter that excepts all requests and just before the filter exists, I can verify I get the expected status from the rest of the chain.
This is an example of a controller code:
@RequestMapping(value = "/{book}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
protected Book put(@PathVariable(value = "bookId") String id, @RequestBody @Valid Book book) {
return book; // just a stub
}
And this is the relevant part in the filter:
filterChain.doFilter(req, res);
// res.getStatus() is the expected status
return; // after this line I move to internal code of Tomcat which I cannot debug, but something happens there.
What do I miss?
Thanks
Upvotes: 0
Views: 299
Reputation: 71
Your path variable value is bookId, but your url uses {book}; both should match. Try changing the url to "/{bookId}" or the path variable to @PathVariable(value = "book"). It might be useful to know the URL that you are calling to help analyse the issue.
Upvotes: 0
Reputation: 735
Upvotes: 0