title: encode specific part of url in Java
body: <p>Here is my url:</p>
  <pre><code>https:/app.mycompany.com/app/login?pagereq=dogs?dogId=123&amp;size=small&amp;color=white
  </code></pre>
  <p>Specifically, I would like to encode only the part <strong>after</strong> the word &quot;dogs&quot;:</p>
  <pre><code>https:/app.mycompany.com/app/login?pagereq=dogs%3FdogId=123%26size=small%26color=white
  </code></pre>
  <p>If I use <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html" rel="nofollow noreferrer">UriComponentsBuilder</a>, it only replaces the first &quot;?&quot; symbol, which I want to retain. it also does not replace the &quot;&amp;&quot; symbols.</p>