title: How to pass map from localstorage to controller in spring boot?
body: <p>I am trying to save checkbox values in localstorage using map. so that i can filter result using map. I am able to store map key-values in localstorage using javascript. but later when i retreive and pass map from localstorage to controller, I am getting map with null values. </p>
  
  <p>this is my code </p>
  
  <p>store map in localstorage</p>
  
  <pre><code>$(':checkbox[name=brand]').on('change', function() {
      var assignedTo = $(':checkbox[name=brand]:checked').map(function() {
          return this.id;
      }).get();
      localStorage.setItem('brands', JSON.stringify(assignedTo))
  });
  </code></pre>
  
  <p>localstorage</p>
  
  <p><a href="https://i.stack.imgur.com/U9quy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U9quy.jpg" alt="enter image description here"></a></p>
  
  <p>passing to controller</p>
  
  <pre><code>$.ajax({
      type : "POST",
      url : "filter",
      data : {
          txtMaxAge : localStorage.getItem('txtMaxAge'),
          brands : JSON.parse(localStorage.getItem("brands"))
  
      }, // parameters
      success : function(result) {
          // alert('changed');
          }
  });
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>@RequestMapping("/filter")
  @ResponseBody
  public String filter(
          @RequestParam(value = "txtMaxAge", required = false) String txtMaxAge,
          @RequestParam(value = "brands", required = false) Map&lt;String, String&gt; brands,
          HttpServletRequest request, HttpServletResponse response) {
  
      System.out.println("max"+txtMaxAge);
  
      System.out.println("printing map----");
  
           for (Map.Entry&lt;String,String&gt; entry : brands.entrySet())  
              System.out.println("Key = " + entry.getKey() + 
                               ", Value = " + entry.getValue()); 
      return "send data";
  }
  </code></pre>
  
  <p>I am getting this error</p>
  
  <pre><code>max10000000
  printing map----
  2018-12-15 13:37:59.142  WARN 13672 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver :
  Resolved [java.lang.NullPointerException] to ModelAndView: reference to view with name 'error';
  model is {errorTitle=Contact Your Administrator!!, errorDescription=java.lang.NullPointerException
  </code></pre>
  
  <p>What i am doing wrong here?</p>