title: How to access URL parameters in spring boot
body: <p>My request is like below :-</p>
  
  <pre><code>http://example.com:8984/service/response?q=bags&amp;source=desktop.search&amp;city.data=mumbai|delhi
  </code></pre>
  
  <p>How can i access these values from the url such that i get the below map :-</p>
  
  <pre><code>{
  q =&gt; bags,
  source =&gt; desktop.search,
  city.data =&gt; [mumbai, delhi]
  }
  </code></pre>
  
  <p>i have written the below program :-</p>
  
  <pre><code>import java.util.Map;
  
  import javax.servlet.http.HttpServletRequest;
  
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class serviceController {
  
      @RequestMapping("/service/response")
  
      String getSearchString(@RequestParam Map&lt;String, String&gt; params) {
          return "SearchString ---- "+params;
      }
  }
  </code></pre>
  
  <p>It is working fine when i giving only 1 parameter in city.data=mumbai
  But getting below error when i am giving city.data=mumbai|delhi</p>
  
  <pre><code>java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
      at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:467) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.13.jar:9.0.13]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791) [tomcat-embed-core-9.0.13.jar:9.0.13]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) [tomcat-embed-core-9.0.13.jar:9.0.13]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.13.jar:9.0.13]
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) [na:na]
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [na:na]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.13.jar:9.0.13]
      at java.base/java.lang.Thread.run(Thread.java:844) [na:na]
  </code></pre>
  
  <p>Please suggest the correct way ?
  thanks in advance</p>