title: RequestParam shows null value
body: <p>I'm trying to retrieve the value from view and use it in controller by using RequestParam. However, the RequestParam attribute shows null.
  Below is my code -
  JSP Page</p>
  <pre><code>    &lt;form th:action=&quot;@{/schedule}&quot; method=&quot;post&quot;&gt;
          &lt;!-- page start--&gt;
          &lt;div class=&quot;row&quot;&gt;
            &lt;div class=&quot;col-lg-12&quot;&gt;
              &lt;h3 class=&quot;page-header&quot;&gt;&lt;i class=&quot;fa fa fa-bars&quot;&gt;&lt;/i&gt; SCHEDULE APPOINTMENT &lt;/h3&gt;
              &lt;ol class=&quot;breadcrumb&quot;&gt;
                &lt;li&gt;&lt;i class=&quot;fa fa-home&quot;&gt;&lt;/i&gt;&lt;a th:href=&quot;@{/index}&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;i class=&quot;fa fa-bars&quot;&gt;&lt;/i&gt;Pages&lt;/li&gt;
                &lt;li&gt;&lt;i class=&quot;fa fa-bars&quot;&gt;&lt;/i&gt;Page&lt;/li&gt;
              &lt;/ol&gt;
            &lt;/div&gt;
          &lt;/div&gt;
               
          &lt;div class=&quot;form-group&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                      &lt;label for=&quot;appointmentDatePicker&quot; class=&quot;col-form-label&quot;&gt;Select Date&lt;font color=&quot;red&quot;&gt;*&lt;/font&gt;&lt;/label&gt;
                      &lt;input type=&quot;date&quot; id=&quot;appointmentDatePicker&quot; name=&quot;appointmentDatePicker&quot; onchange=&quot;myFunction()&quot; required&gt;
              &lt;/div&gt;
              &lt;div class=&quot;form-group&quot;&gt;        
                      &lt;label for=&quot;appointmentDate&quot; class=&quot;col-form-label&quot;&gt;Date&lt;/label&gt;
                      &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;appointmentDate&quot; name=&quot;appointmentDate&quot; readonly=&quot;readonly&quot;&gt;
                      &lt;script&gt;
                      function myFunction() {
                        //document.getElementById(&quot;2&quot;).disabled = true;
                          //var j = document.getElementById(&quot;appointmentDate&quot;);
                          //j.innerHTML = document.getElementById(&quot;appointmentDatePicker&quot;).value;
                          var aptDate = document.getElementById(&quot;appointmentDatePicker&quot;).value;
                          alert(aptDate);
                          document.getElementById(&quot;appointmentDate&quot;).value = aptDate;
                      }
                      &lt;/script&gt;
              &lt;/div&gt;
              &lt;a th:href=&quot;@{/viewApp}&quot;&gt;View Appointments&lt;/a&gt;  
          &lt;/div&gt;
         
          &lt;div class=&quot;form-group&quot;&gt;
              &lt;label for=&quot;appointment&quot; class=&quot;col-sm-4 col-form-label&quot;&gt;List of Available appointment slots&lt;/label&gt;
                  &lt;select id=&quot;appointmentId&quot; name=&quot;appointmentId&quot; &gt;
                     &lt;option value=&quot;&quot;&gt;Please Select&lt;/option&gt;                                                                              
                     &lt;option th:each=&quot;appointment : ${appointmentList}&quot;
                          th:unless=&quot;${appointment.appointmentStatus}&quot;
                          th:value=&quot;${appointment.appointmentId}&quot;
                          th:text=&quot;${appointment.displayTime}&quot;&gt;
                     &lt;/option&gt;
                  &lt;/select&gt;
            &lt;/div&gt;  
            &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Schedule Appointment&lt;/button&gt;    
            &lt;/form&gt;
   &lt;!-- page end--&gt;
  </code></pre>
  <p>Controller code</p>
  <pre><code>@GetMapping(&quot;/viewApp&quot;) 
      public String ViewAppointmentList(Model model ,  RedirectAttributes redir, 
                                                      @RequestParam(value =&quot;appointmentDate&quot;, required = false) String appointmentDate
                                                      ,@RequestParam(value =&quot;appointmentDatePicker&quot;, required = false) String appointmentDatePicker) {
          System.out.println(&quot;In view of scheduleApp&quot;);
          
            System.out.println(&quot;Date is &quot;+appointmentDate); 
            System.out.println(&quot;appointmentDatePicker &quot; +appointmentDatePicker);
          
              //get the date set
            List&lt;Appointment&gt; appointmentList = appointmentService.getAppointments();
            appointmentList.forEach(appointment -&gt; appointment.setDisplayTime(appointment.getTimeFrom(),appointment.getTimeTo()));
            
            List&lt;Appointment&gt; appointmentListByDate = new ArrayList&lt;Appointment&gt;(); 
            for (Appointment appointment:appointmentList) 
            { 
                //if condition to filter depending upon date
                    appointment.setDisplayTime(appointment.getTimeFrom(),appointment.getTimeTo()); appointmentListByDate.add(appointment);
                    System.out.println(&quot;appointment date &quot; + appointment.getTimeFrom()); 
                    
            }
            
            //model.addAttribute(&quot;appointmentList&quot;, appointmentListByDate);       
            redir.addFlashAttribute(&quot;appointmentList&quot;, appointmentListByDate);
          
            return &quot;redirect:/scheduleApp&quot;;
      }
  </code></pre>
  <p>The console shows as below</p>
  <pre><code>In view of scheduleApp
  Date is null
  appointmentDatePicker null
  </code></pre>
  <p>Edited JSP page code to show the form code.
  I'm newbie to MVC and can someone correct me where I'm wrong?
  Thanks in Advance!</p>