title: Spring controller to work similarly to both GET and POST methods
body: <p>I have a method like below in my Spring application</p>
  
  <pre><code>@RequestMapping(value = "/search-result-doctors", method = RequestMethod.POST)
  public String getDoctorSearchResults(String LastName, String Hospital, String Specialty, String date1, ModelMap model) {
      //some logics
  
       return "doctorchannelling/search-result-doctors";
  }
  </code></pre>
  
  <p>after going in to the page "search-result-doctors" when I press the just Enter in the URL it has to remain in the same page. Since it is a GET request I have written the same method again with a method value RequestMethod.GET.</p>
  
  <pre><code>@RequestMapping(value = "/search-result-doctors", method = RequestMethod.GET)
  public String getDoctorSearchResults(String LastName, String Hospital, String Specialty, String date1, ModelMap model) {
      //some logics
  
      return "doctorchannelling/search-result-doctors";
  }
  </code></pre>
  
  <p>due to the unavailability of parameter values String LastName, String Hospital, String Specialty, String date1 in the GET request i'm getting a Exception</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
  </code></pre>
  
  <p>How can I resolve this problem</p>
  
  <p>Thanks in advance</p>