title: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
body: <p>I am new in the Spring World and writing even my first Jquery. trying to get the JSON data from JSP page using Ajax call, to the controller. But i am getting error  org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported. Please do help.</p>
  
  <p>Dependencies:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
      &lt;version&gt;${spring.version}&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
      &lt;version&gt;${spring.version}&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
      &lt;version&gt;${jackson-asl}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>register.jsp</p>
  
  <pre><code>&lt;script
      src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      alert("submit");
      $(document).ready(function() {
          alert("documet");
          $('#idForm').submit(function(e) {
              alert("idForm");
              e.preventDefault();
              alert("INSIDE jquery");
              var fName = $('#fName').val();
              var mName = $('#mName').val();
              var lName = $('#lName').val();
              var uName = $('#uName').val();
              var email = $('#email').val();
              var password = $('#password').val();
              var mobile = $('#mobile').val();
              var gender = $('#gender').val();
              var user = {
                  "fname" : fName,
                  "mName" : mName,
                  "lName" : lName,
                  "uName" : uName,
                  "email" : email,
                  "password" : password,
                  "mobile" : mobile,
                  "gender" : gender
              };
  
              alert(user);
  
              $.ajax({
                  url : $('#idForm').action,
                  dataType : 'json',
                  type : 'POST',
                  async : false,
                  data : JSON.stringify(user), //Stringified Json Object
                  contentType : 'application/json',
                  mimeType : 'application/json',
                  success : function(user) {
                      alert(user);
                  }
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Controller.Java</p>
  
  <pre><code>@RequestMapping(value = "/register", method = RequestMethod.POST)
      public String registerPost(@RequestBody  UserInfo user) {
          LOG.info(user);
          return "login";
      }
  </code></pre>
  
  <p>Model Class: UserInfo.java
  package com.shop.model;</p>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "userinfo")
  public class UserInfo {
  
      private int userId;
      private String fName;
      private String mName;
      private String lName;
      private String uName;
      private String email;
      private String password;
      private String Gender;
      private Long mobile;
  
      public UserInfo() {
  
      }
  
      public UserInfo(int userId, String fName, String mName, String lName,
              String uName, String email, String password, String gender,
              Long mobile) {
          super();
          this.userId = userId;
          this.fName = fName;
          this.mName = mName;
          this.lName = lName;
          this.uName = uName;
          this.email = email;
          this.password = password;
          Gender = gender;
          this.mobile = mobile;
      }
  
      @Override
      public String toString() {
          return "UserInfo [userId=" + userId + ", fName=" + fName + ", mName="
                  + mName + ", lName=" + lName + ", uName=" + uName + ", email="
                  + email + ", password=" + password + ", Gender=" + Gender
                  + ", mobile=" + mobile + "]";
      }
  
      @Id
      @GeneratedValue
      @Column(name = "userId", unique = true, nullable = false, length = 11)
      public int getUserId() {
          return userId;
      }
  
      public void setUserId(int userId) {
          this.userId = userId;
      }
  
      @Column(name = "email", unique = true, nullable = false, length = 45)
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      @Column(name = "password", unique = true, nullable = false, length = 45)
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      @Column(name = "FirstName", nullable = false, length = 45)
      public String getfName() {
          return fName;
      }
  
      public void setfName(String fName) {
          this.fName = fName;
      }
  
      @Column(name = "middleName", nullable = false, length = 45)
      public String getmName() {
          return mName;
      }
  
      public void setmName(String mName) {
          this.mName = mName;
      }
  
      @Column(name = "LastName", nullable = false, length = 45)
      public String getlName() {
          return lName;
      }
  
      public void setlName(String lName) {
          this.lName = lName;
      }
  
      @Column(name = "uName", unique = true, nullable = false, length = 45)
      public String getuName() {
          return uName;
      }
  
      public void setuName(String uName) {
          this.uName = uName;
      }
  
      @Column(name = "Gender", nullable = false, length = 45)
      public String getGender() {
          return Gender;
      }
  
      public void setGender(String gender) {
          Gender = gender;
      }
  
      @Column(name = "Mobile", nullable = false, length = 45)
      public Long getMobile() {
          return mobile;
      }
  
      public void setMobile(Long mobile) {
          this.mobile = mobile;
      }
  
  }
  </code></pre>