title: Spring Web MVC huge performance issues when rendering view
body: <p>I'm making a project with the Spring Framework and I use the Spring MVC Framework for building my views.</p>
  
  <p>Now everything works fine and runs smooth except for this simple GET page that takes 2 seconds and sometimes more to load on localhost.</p>
  
  <p>As you can see in the logs (link) there is this very slow GenericConversionService trying to find converters to bind properties. </p>
  
  <p>Help would really be appreciated!</p>
  
  <p>Thanks in advance (appologies for my spelling errors) :)</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Apperantly the conversion service runs for every (binded with Path attribute) form tag in the "<a href="http://www.springframework.org/tags/form" rel="nofollow noreferrer">http://www.springframework.org/tags/form</a>" namespace. The more form tags I Use the slower my page loads. Should I be using normal html form tags to increase performance or is there a way to stop it from looking for the "right" converter?</p>
  
  <p><strong>Additional information:</strong></p>
  
  <p>Logs:
  <a href="http://paste2.org/p/1292370" rel="nofollow noreferrer">Link</a> (Scroll about 1/3 there you will see a massive chunk of GenericConversionService  logs</p>
  
  <p>Spring insight profiling information: <img src="https://i.stack.imgur.com/GKOmr.png" alt="Profile information"></p>
  
  <p>Controller (Sloppy) Code:</p>
  
  <pre><code>@RequestMapping(value = "/route/create", method = RequestMethod.GET)
  public ModelAndView getCreateRoute(){
      RouteCreateUpdateViewModel result = new RouteCreateUpdateViewModel();
      User u = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      u = us.get(u.getId());
  
      ModelAndView mav = new ModelAndView("route/create", "routeCreateUpdateModel", result);
      mav.addObject("favLocations", u.getLocations());
      mav.addObject("cars", u.getCars());
  
      result.setDateDay(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + 1); // January = 0
      result.setDateMonth(Calendar.getInstance().get(Calendar.MONTH));
      result.setDateYear(Calendar.getInstance().get(Calendar.YEAR));
  
      mav.addObject("nextYear", result.getDateYear() + 1);
  
      return mav;
  }
  </code></pre>
  
  <p>View Code:</p>
  
  <pre><code>    &lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %&gt;
  
  
  &lt;!-- //TODO I18N --&gt;
  
  &lt;style type="text/css"&gt;
      li:focus {
          background-color:green;
      }
  &lt;/style&gt;
  
  &lt;script&gt;
      var highlightedElement = null;
      $(document).ready(function(){
          $("input,select").click(function() {
              if(highlightedElement != null)
              {
                  $(highlightedElement).removeClass("curFocus");
                  if(highlightedElement.hasClass("location"))
                  {
                      checkLocation(highlightedElement);
                  }
              }
              var newHighlightedElement = $(this).parent().parent();
              $(newHighlightedElement).addClass("curFocus");
              highlightedElement = newHighlightedElement;
          });
      });
  
      function checkLocation(highlightedElement)
      {
          var parameters = {
          zipcode: $(highlightedElement).find(".zipcode").val(),
          street: $(highlightedElement).find(".street").val(),
          streetNr: $(highlightedElement).find(".streetNr").val()
          };
  
          $.getJSON('/location/validate.php', parameters, function(data) {
              if(data.result != null)
              {
                  $(highlightedElement).removeClass("badData");
                  $(highlightedElement).addClass("goodData");
              }
              else {
                  $(highlightedElement).removeClass("goodData")
                  $(highlightedElement).addClass("badData");
              }
          });
      }
  
  &lt;/script&gt;
  
  &lt;div&gt;
      &lt;h1&gt;&lt;fmt:message key="route.create.header"/&gt;&lt;/h1&gt;
      &lt;div class="form-container"&gt;
          &lt;c:url value="/route/create.php" var="actUrl"/&gt;
          &lt;form:form method="POST" action="${actUrl}" modelAttribute="routeCreateUpdateModel"&gt;
              &lt;ul&gt;
                  &lt;li class="location"&gt;
                      &lt;form:label path="fromZipcode" cssClass="title"&gt;Van&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                  &lt;span&gt;
                      &lt;form:input path="fromZipcode" cssClass="zipcode"/&gt;
                      &lt;form:label path="fromZipcode" cssClass="desc"&gt;Gemeente&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                      &lt;form:input path="fromStreet" cssClass="street"/&gt;
                      &lt;form:label path="fromStreet" cssClass="desc"&gt;Straat&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                      &lt;form:input path="fromStreetNr" cssClass="streetNr"/&gt;
                      &lt;form:label path="fromStreetNr" cssClass="desc"&gt;Nr&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li class="location"&gt;
                      &lt;form:label path="toZipcode" cssClass="title"&gt;Naar&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                  &lt;span&gt;
                      &lt;form:input path="toZipcode" cssClass="zipcode"/&gt;
                      &lt;form:label path="toZipcode" cssClass="desc"&gt;Gemeente&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                      &lt;form:input path="toStreet" cssClass="street"/&gt;
                      &lt;form:label path="toStreet" cssClass="desc"&gt;Straat&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                      &lt;form:input path="toStreetNr" cssClass="streetNr"/&gt;
                      &lt;form:label path="toStreetNr" cssClass="desc"&gt;Nr&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;form:label path="dateDay" cssClass="title"&gt;Datum&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                  &lt;span&gt;
                     &lt;tags:showDayPicker path="dateDay" currentDay="${routeCreateUpdateModel.dateDay}"/&gt;
                      &lt;form:label path="dateDay" cssClass="desc"&gt;dd&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                     &lt;tags:showMonthPicker path="dateMonth" currentMonth="${routeCreateUpdateModel.dateMonth}"/&gt;
                      &lt;form:label path="dateMonth" cssClass="desc"&gt;mm&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                     &lt;tags:showYearPicker path="dateYear" startYear="${routeCreateUpdateModel.dateYear}"
                                          stopYear="${nextYear}"/&gt;
                      &lt;form:label path="dateYear" cssClass="desc"&gt;yyyy&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                       &lt;form:label path="days" cssClass="title"&gt;Dagen&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="1"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Ma&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="2"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Di&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="3"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Wo&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="4"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Do&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="5"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Vrij&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="6"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Za&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;form:checkbox path="days" value="7"/&gt;
                          &lt;form:label path="days" cssClass="desc"&gt;Zo&lt;/form:label&gt;
                      &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;form:label path="stopDateDay" cssClass="title"&gt;Herhalen tot&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                  &lt;span&gt;
                     &lt;tags:showDayPicker path="stopDateDay" currentDay="${routeCreateUpdateModel.dateDay}"/&gt;
                      &lt;form:label path="stopDateDay" cssClass="desc"&gt;dd&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                     &lt;tags:showMonthPicker path="stopDateMonth" currentMonth="${routeCreateUpdateModel.dateMonth}"/&gt;
                      &lt;form:label path="stopDateMonth" cssClass="desc"&gt;mm&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                     &lt;tags:showYearPicker path="stopDateYear" startYear="${routeCreateUpdateModel.dateYear}"
                                          stopYear="${nextYear}"/&gt;
                      &lt;form:label path="stopDateYear" cssClass="desc"&gt;yyyy&lt;/form:label&gt;
                  &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;form:label path="departureTime" cssClass="title"&gt;Vertrek uur&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                      &lt;span&gt;
                          &lt;tags:showHourPicker path="departureTime"/&gt;
                          &lt;form:label path="departureTime" cssClass="desc"&gt;uu&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;tags:showMinutePicker path="departureTime"/&gt;
                          &lt;form:label path="departureTime" cssClass="desc"&gt;mm&lt;/form:label&gt;
                      &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;form:label path="arrivalTime" cssClass="title"&gt;Aankomst uur&lt;span class="required"&gt;*&lt;/span&gt;&lt;/form:label&gt;
                      &lt;span&gt;
                          &lt;tags:showHourPicker path="arrivalTime"/&gt;
                          &lt;form:label path="arrivalTime" cssClass="desc"&gt;uu&lt;/form:label&gt;
                      &lt;/span&gt;
                      &lt;span&gt;
                          &lt;tags:showMinutePicker path="arrivalTime"/&gt;
                          &lt;form:label path="arrivalTime" cssClass="desc"&gt;mm&lt;/form:label&gt;
                      &lt;/span&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;form:label path="car" cssClass="title"&gt;Auto&lt;/form:label&gt;
                      &lt;span&gt;
                          &lt;form:select path="car"&gt;
                              &lt;form:options items="${cars}" itemLabel="carName" itemValue="Id" /&gt;
                          &lt;/form:select&gt;
                      &lt;/span&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
              &lt;input type="submit" value="Route toevoegen"/&gt;
          &lt;/form:form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If you need any more information just ask and I will provide it right away.</p>
  
  <p>Thanks again :)</p>