title: How to encode field entities in URL in Spring MVC?
body: <p>I made a form submit application via Spring MVC. After submitting the form, all values of input fields are visible in url.</p>
  
  <p><strong>let's suppose that after submitting the generated URL is this:</strong></p>
  
  <p><em>SpringTuto/successA?name=FirstUser&amp;designation=Student&amp;country=XYZ&amp;dob=2018%2F01%2F16&amp;skills=paragliding&amp;address.street_name=avenue+Road&amp;address.city=New+City&amp;address.district=New+District&amp;address.pin_code=322343</em></p>
  
  <p>From the above url, I want to encode name, designation, country and all other parameters in some encrypted code.</p>
  
  <p>After reading a few articles, i came to an understanding that I will use the URIeditor(org.springframework.beans.propertyeditors.URIEditor) to encode. But I don't know how to use it. If anyone has another way to do this please share it.
  Thanks in advance.</p>
  
  <p>Here is my Controller Class.</p>
  
  <p>@Controller
  public class SpgController {</p>
  
  <pre><code>@ModelAttribute("header")
  public Model addHeader(Model view) {
      int a = 10;
      return view.addAttribute(a);
  
  }
  @InitBinder
  public void initBinder(WebDataBinder binder) {
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/mm/dd");
      binder.registerCustomEditor(Date.class, "dob", new CustomDateEditor(dateFormat, false));
      binder.registerCustomEditor(String.class, "name" , new NamepropertyEditor());
  }
  
  
  
  @RequestMapping("/main")
  public ModelAndView go() {
      ModelAndView view = new ModelAndView("main");
      return view;
  }
  
  
  @RequestMapping(value = "/successA", method = RequestMethod.GET)
  public ModelAndView method(@Valid @ModelAttribute("bean") Bean bean, BindingResult result ) {
      if (result.hasErrors()) {
          ModelAndView view = new ModelAndView("main");
          return view;
      }
  
      ModelAndView view = new ModelAndView("successAnother");
      return view;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is the successAnother.jsp page</p>
  
  <pre><code>     &lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form &gt;
          Name: ${bean.name}&lt;br/&gt;
          Designation: ${bean.designation}&lt;br/&gt;
          DoB: ${bean.dob}&lt;br/&gt;
          Skills: ${bean.skills}&lt;br/&gt;
          Street: ${bean.address.street_name}&lt;br/&gt;
          City: ${bean.address.city}&lt;br/&gt;
          District: ${bean.address.district}&lt;br/&gt;
          PinCode: ${bean.address.pin_code}&lt;br/&gt;
          Country: ${bean.country}&lt;br/&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is main.jsp(Application form)</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
      &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;  
      &lt;%@ taglib uri="http://www.springframework.org/tags" prefix = "spring" %&gt;  
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Spring&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;a href = "/SpringTuto/main?language=en"&gt;English&lt;/a&gt;|&lt;a href = "/SpringTuto/main?language=fr"&gt;French&lt;/a&gt;|&lt;a href = "/SpringTuto/main?language=hi"&gt;Hindi&lt;/a&gt;
  
      &lt;h3&gt;${msg}&lt;/h3&gt;
      &lt;form:errors path = "bean.*"/&gt;
      &lt;form action="successA" method="get"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;spring:message code = "label.userName"/&gt;&lt;input type="text" name="name"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;spring:message code = "label.userDesignation"/&gt;&lt;input type="text" name="designation"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;spring:message code = "label.userCountry"/&gt;&lt;input type="text" name="country"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;spring:message code = "label.userDoB"/&gt;&lt;input type= "text" name = "dob"  &gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;spring:message code = "label.Skils"/&gt;&lt;select name = "skills" multiple &gt;
                          &lt;option value= "driving"&gt;Driving&lt;/option&gt;
                          &lt;option value = "diving"&gt;Diving&lt;/option&gt;
                          &lt;option value = "swimming"&gt;Swimming&lt;/option&gt;
                          &lt;option value  = "paragliding"&gt;Paragliding&lt;/option&gt;
                      &lt;/select&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;h5&gt;&lt;spring:message code = "label.userAddress"/&gt;&lt;/h5&gt;
                          &lt;spring:message code = "label.userStreetname"/&gt;&lt;input type = "text" name = "address.street_name"&gt;
                          &lt;spring:message code = "label.userCity"/&gt; &lt;input type = "text" name = "address.city"&gt;
                          &lt;spring:message code = "label.userDistrict"/&gt;&lt;input type = "text" name  = "address.district"&gt;
                          &lt;spring:message code = "label.userPin"/&gt;&lt;input type  = "text" name = "address.pin_code"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
  
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="submit" value=&lt;spring:message code = "label.userSubmit"/&gt;&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>