0

I am using UriComponentsBuilder and sending a url on mail which contains "?" but instead of "?" it get converted to the unicode value of "?" i.e.,"%3F", kindly suggest how can I send this URL so that I would get the exact "?" that I want.

Here is the code that I am using.

 UriComponentsBuilder urlBuilder = ServletUriComponentsBuilder.fromCurrentContextPath().path("/registrationConfirmation"+"?token="+registrationToken);

    String onUserRegistrationCompleteEvent = mailService.onUserRegistrationCompleteEvent(registeredUserOpt.get().getEmail(), urlBuilder.toUriString());
  • Possible duplicate of [URL encoding using the new Spring UriComponentsBuilder](https://stackoverflow.com/questions/18138011/url-encoding-using-the-new-spring-uricomponentsbuilder) – dbl Nov 20 '18 at 09:48
  • hi dbl I had seen that link earlier but it does not contain the answer of my question kindly go through it once again and let me know if you have better suggestion on the same – Awnish Sharma Nov 20 '18 at 09:54
  • You are right, there is no explicit answer to your question there but there are some leads. Take a look at [this baeldung article](https://www.baeldung.com/spring-uricomponentsbuilder)(3.4 in particular) to try to understand how UriComponentsBuilder really works. – dbl Nov 20 '18 at 10:02
  • 1
    Thanks, it is solved we did not have to mention the parameter in URL as I had done, instead we have to put as urlBuilder.queryParam("token",registrationToken) – Awnish Sharma Nov 20 '18 at 10:08
  • If you take a closer look at some of the answers from the possible duplicate, they have such approaches proposed. – dbl Nov 20 '18 at 10:12

0 Answers0