title: Spring REST Controller for StringEntity
body: <p>I am creating Web Service using Spring 4.0 REST Api , I am having following Android HttpClient code but I am getting 404 error from server , I need best Spring controller code which will work with my following Android HttpClient </p>
  
  <pre><code>void call() {
          HttpClient client = new DefaultHttpClient();
          HttpPost post = new HttpPost("http://192.168.0.15:8080/locate/register");
          post.setHeader("Content-type", "application/json");
          post.setHeader("Accept", "application/json");
          JSONObject obj = new JSONObject();
          obj.put("userId", "1111");
          obj.put("mobileNumber", "1111111");
              obj.put("userName", "abc");
              obj.put("password", "abc");
              obj.put("email", "abc@a.com");
              obj.put("meiNumber", "876535354");
              post.setEntity(new StringEntity(obj.toString(), "UTF-8"));
          HttpResponse response = client.execute(post);
      }
  </code></pre>
  
  <p>presently I have written spring controller which has one method as follows , I want to return same object or anything which is in JSON only, also explain why following method is not working with my android client code ..</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, value = "/register", headers = "Accept=application/json")
      public @ResponseBody UserRegistration registerUser(@RequestBody UserRegistration user) {
                // my business logic
                  return user;
      }
  </code></pre>
  
  <p>I am pasting UserRegistration model here</p>
  
  <pre><code>public class UserRegistration implements Serializable {
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
      private long userId;
      private String mobileNumber;
      private String userName;
      private String password;
      private String email;
      private String imeiNumber;
  
      private Date registrationDate;
  
  
      public long getUserId() {
          return userId;
      }
  
      public void setUserId(long userId) {
          this.userId = userId;
      }
  
  
      public String getMobileNumber() {
          return mobileNumber;
      }
  
      public void setMobileNumber(String mobileNumber) {
          this.mobileNumber = mobileNumber;
      }
  
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
  
      public String getImeiNumber() {
          return imeiNumber;
      }
  
      public void setImeiNumber(String imeiNumber) {
          this.imeiNumber = imeiNumber;
      }
  
      public Date getRegistrationDate() {
          return registrationDate;
      }
  
      public void setRegistrationDate(Date registrationDate) {
          this.registrationDate = registrationDate;
      }
  }
  </code></pre>
  
  <p>please help me to resolve this .. </p>