title: Spring REST 400 Bad Request with x-www-urlformencoded POST of Body to @ModelAttribute Domain Object
body: <blockquote>
  <p>Hi, I am reaching out in the hopes that I am overlooking something trivial. I don't see any problem with the url encodning post here. I can't get the details of my 400 Bad Request exception message despite my trying to catch it. It is possibly a class I am not mapping to in my handler.</p>
  <p>Anyway, this works with a plain application/json post, but has problems with the posting via url encoding. I am not even reaching my controller , therefore I am fairly sure that this is a binding problem to my sample entity when url encoding is involved. It binds fine when I use @RequestBody and post using application/json, but has problems with @ModelAttribute when posting via urlencoding. What is it about my body for the urlencoding post that is a problem?</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/fnksg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fnksg.png" alt="enter image description here" /></a></p>
  <blockquote>
  <p>Bulk Edit Text</p>
  </blockquote>
  <pre><code>firstName:JohnTest
  lastName:Stafford
  birthDate:1990-08-07
  driversLicenseNumber:080005900
  address:1700NW36thTerraceYukonOklahoma
  zip:73099
  email:john.charles.stafford@gmail.com
  homePhone:4055506800
  workPhone:4055506800
  amount:300
  employer:meMyselfAndI
  activeMilitary:0
  incomeType:EMPLOYMENT
  monthlyIncome:12000
  date1:2016-12-02
  date2:2016-12-16
  frequency:TWICEMONTHLY
  </code></pre>
  <blockquote>
  <p>Controller method used for the x-www-formurlencoded POST</p>
  </blockquote>
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.CREATED)
  @ResponseBody
  public Lead save(@Valid @ModelAttribute(&quot;entity&quot;) final SampleEntity entity)   
  {
      return createInternal(entity);
  }
  </code></pre>
  <blockquote>
  <p>SampleEntity (again, this works for an application/json POST)</p>
  </blockquote>
  <pre><code>@Entity
  @Table(name=&quot;sample_table&quot;)
  public class SampleEntity implements IBaseEntity{
  
  /**
   * 
   */
  private static final long serialVersionUID = -1110216193971231355L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = &quot;id&quot;)
  private Long id;
  
  @Column(name = &quot;first_name&quot;)
  @NotNull
  private String firstName;
  
  @Column(name = &quot;last_name&quot;)
  @NotNull
  private String lastName;
  
  @Column(name = &quot;birth_date&quot;)
  @NotNull
  private String birthDate;
  
  @Column(name = &quot;drivers_license_number&quot;)
  @NotNull
  private String driversLicenseNumber;
  
  @Column
  @NotNull
  private String address;
  
  @Column
  @NotNull
  private String zip;
  
  @Column
  @NotNull
  private String email;
  
  @Column(name = &quot;home_phone&quot;)
  @NotNull
  private String homePhone;
  
  @Column(name = &quot;work_phone&quot;)
  @NotNull
  private String workPhone;
  
  @Column(name = &quot;requested_amount&quot;)
  @NotNull
  private String requestedAmount;
  
  @Column
  @NotNull
  private String employer;
  
  @Column(name = &quot;active_military&quot;)
  @NotNull
  private String activeMilitary;
  
  @Column(name = &quot;income_type&quot;)
  @NotNull
  private String incomeType;
  
  @Column(name = &quot;monthly_income&quot;)
  @NotNull
  private String monthlyIncome;
  
  @Column
  @Temporal(TemporalType.DATE)
  @NotNull
  private Date date1;
  
  @Column
  @Temporal(TemporalType.DATE)
  @NotNull
  private Date date2;
  
  @Column(name = &quot;frequency&quot;)
  @NotNull
  private String frequency;
  
  //getters and setters
  </code></pre>
  <blockquote>
  <p>Any help greatly appreciated. Thanks.</p>
  </blockquote>