2

I,m new to spring, I,m writing REST API. I/'m getting 403 forbidden error for delete, put. Following is the sample I'm working on.

@RequestMapping(value = "/{noteId}", method = RequestMethod.PUT) public ResponseEntity noteIdPut( @PathVariable("Id") String Id, Note note) throws Exception { return service.updateNote(Id, note); } 

1 Answer 1

3

Just add these filter line in web.xml.

<filter> <filter-name>CorsFilter</filter-name> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> <init-param> <param-name>cors.allowed.origins</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.allowed.headers</param-name> <param-value>Content-Type,X-Requested-With,accept,authorization,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value> </init-param> <init-param> <param-name>cors.allowed.methods</param-name> <param-value>GET, POST, PUT, DELETE, OPTIONS, HEAD</param-value> </init-param> </filter> 
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the response. I'll try and let you know
Lifesaver! I was debugging a similar issue and it worked like magic, could have saved me a few hours if I came straight here.
how to achieve this in java file?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.