title: HTTP Status 400 The request sent by the client was syntactically incorrect in Spring
body: <p>I have created a MVC structure to save a new record for patient and i keep getting 404 error. Here is my code,</p>
  
  <p>Patient.java</p>
  
  <pre><code>public class Patient {
  private int patient_ID;
  private String  name;
  private String gender;
  private int age;
  private Date dob;
  
  public Patient(){
  
  }
  
  public Patient(int patient_ID, String name, String gender, int age, Date dob) {
      this.patient_ID = patient_ID;
      this.name = name;
      this.gender = gender;
      this.age = age;
      this.dob = dob;
  }
  public int getPatient_ID() {
      return patient_ID;
  }
  public void setPatient_ID(int patient_ID) {
      this.patient_ID = patient_ID;
  }
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  public String getGender() {
      return gender;
  }
  public void setGender(String gender) {
      this.gender = gender;
  }
  public int getAge() {
      return age;
  }
  public void setAge(int age) {
      this.age = age;
  }
  public Date getDob() {
      return dob;
  }
  public void setDob(Date dob) {
      this.dob = dob;
  }
  
  }
  </code></pre>
  
  <p>The Controller Class</p>
  
  <pre><code>@Controller
  public class PatientController {
  
  @RequestMapping(value="/newPatient",method=RequestMethod.GET)
  public ModelAndView newPatient(ModelAndView model) {                                                         Patient newpatient  = new Patient();
      model.addObject("patient", newpatient);
      model.setViewName("PatientForm");
      System.out.println("sending to patient form");
      return model;
  }
  
  @RequestMapping(value = "/savePatient", method = RequestMethod.POST)
  public ModelAndView savePatient(ModelAndView model,@ModelAttribute Patient patient) {
  
      PatientDaoImplementation patientDaoImpl = new PatientDaoImplementation();
      patientDaoImpl.saveOrUpdate(patient);
      List&lt;Patient&gt; listPatient = patientDaoImpl.patientList();
      model.addObject("listPatient",listPatient);
      model.setViewName("home");
      return model;
  }
  
  }
  </code></pre>
  
  <p>Dao Implementation class</p>
  
  <pre><code>public class PatientDaoImplementation {
  
  private DataSource dataSource;
  private static JdbcTemplate jdbcTemplate;
  
  public void setDataSource(DataSource dataSource) {
      System.out.println("datasource"+dataSource);
      this.dataSource = dataSource;
      this.setJdbcTemplate(dataSource);
  }
  public void setJdbcTemplate(DataSource ds) {
      this.jdbcTemplate= new JdbcTemplate(ds);
  }
  
  public PatientDaoImplementation(){
  
  }
  
  //get all records in Patient
          public List&lt;Patient&gt; patientList() {
              String sql ="SELECT * from patient";
          List&lt;Patient&gt; listPatient = jdbcTemplate.query(sql, new RowMapper&lt;Patient&gt;(){
                  public Patient mapRow(ResultSet rs, int arg1) throws SQLException {
                      Patient patient = new Patient();
                      patient.setPatient_ID(rs.getInt("Patient_ID"));
                      patient.setName(rs.getString("Name"));
                      patient.setAge(rs.getInt("Age"));
                      patient.setGender(rs.getString("Gender"));
                      patient.setDob(rs.getDate("DOB"));
                      return patient;
                  }
              });
              return listPatient;
          }
  
          public void saveOrUpdate(Patient patient) {
                  //insert
              String sql = "INSERT INTO patient (Patient_ID, Name, Gender, Age,DOB)" + " VALUES (?, ?, ?, ?,?)";
  
                  jdbcTemplate.update(sql, patient.getPatient_ID(),patient.getName(),patient.getGender(),patient.getAge(),patient.getDob());
              }
          }
  </code></pre>
  
  <p>dispatcher servlet</p>
  
  <pre><code>&lt;context:component-scan base-package="com.csc.*" /&gt;
  &lt;bean
  class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/hospital" /&gt;
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="bgowda" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="patientDaoImpl" class="com.csc.bg.daoimpl.PatientDaoImplementation"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>PatientForm.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&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;New Patient&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div align="center"&gt;
          &lt;h1&gt;New Patient&lt;/h1&gt;
           &lt;form:form action="save" method="post" modelAttribute="patient" &gt; 
          &lt;table&gt;
              &lt;form:hidden path="patient_ID"/&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name:&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="name"  /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Gender:&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="gender" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Age:&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="age" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;DOB:&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="dob"  /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" align="center"&gt;&lt;input type="submit" value="Save"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;/form:form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      id="WebApp_ID" version="3.0"&gt;
      &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
      &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/Dispatcher-servlet.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I am able to get the list but when I try to save the patient details from the PatientForm.jsp, the form is not submitting it to the controller giving 400 status error</p>