spring - Redirecting by setting the location in the header -


i have method in rest api which, after call, should set address forwarding

 uricomponents uricomponents = uricomponentsbuilder.path("/signin").build(); 

this not case, however. method

@restcontroller @preauthorize("permitall()") @requestmapping(value = "/register") @api(value = "register api", description = "provides list of methods registration") public class registerrestcontroller {       @apioperation(value = "activate user token")      @requestmapping(value = "/thanks", method = requestmethod.get)      public      responseentity<?> confirmaccount(         @requestparam("token") string token,         uricomponentsbuilder uricomponentsbuilder      ) throws urisyntaxexception {           optional<user> useroptional = userservice.findbyactivationtoken(token);            if(useroptional.ispresent()) {              user user = useroptional.get();               user.setactivationtoken(null);              user.setenabled(true);               userservice.saveuser(user);           } else {              throw new activationtokennotfoundexception();           }            uricomponents uricomponents = uricomponentsbuilder.path("/signin").build();            return responseentity.created(uricomponents.touri()).build();     } } 

there no redirection after calling page address https://zapodaj.net/fa61bfc5732f3.png.html did same on topic on stack overflow enter link description here. address calls link mailbox https://zapodaj.net/e0e5eb8ad52bf.png.html.

browser not redirect on 201 created response. should use permanent redirect (301 moved permanently).

return responseentity.status(301).location(uricomponents.touri()).build(); 

201 response code not make lot of sense method, used response ajax put method request api endpoint.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -