lundi 27 août 2018

Change the request method from POST to GET in a redirection from spring controller

I have a spring mvc controller, which accepts a post request and it needs to redirect to a URL (GET request).

@RequestMapping(value = "/sredirect", method = RequestMethod.POST)
public String processForm(HttpServletRequest request) {
    System.out.println("Ews redirect hit !!! ");
request.setAttribute(View.RESPONSE_STATUS_ATTRIBUTE,HttpStatus.MOVED_PERMANENTLY);

    return "redirect:https://www.google.com/";
}

And the class is annotated with @RestController. I am always getting 405, method not allowed for the redirect url. (i.e google.com).

As per docs (https://tools.ietf.org/html/rfc7238), it should allow the method to be changed . I am not sure what am I doing wrong? Can someone help




Aucun commentaire:

Enregistrer un commentaire