안녕하세요, 저는 사소한 것을 간과하고 있다는 희망에 도달하고 있습니다. 게시물을 인코딩하는 URL에 어떤 문제도 보이지 않습니다. 나는 그것을 잡으려고 노력하면서도 나의 400 Bad Request 예외 메시지의 세부 사항을 얻을 수 없다. 그것은 아마도 내 처리기에서 매핑되지 않는 클래스입니다.X-www-urlformencoded POST를 사용하여 Spring REST 400 불량 요청이 @ModelAttribute 도메인 객체에 대한 몸체의
어쨌든 일반 응용 프로그램/json 게시물에서는 작동하지만 URL 인코딩을 통한 게시에는 문제가 있습니다. 나는 심지어 내 컨트롤러에 도달하지 않기 때문에 URL 인코딩이 관련되어있을 때이 샘플 엔티티에 바인딩 문제가 있음을 알 수 있습니다. @RequestBody를 사용하고 application/json을 사용하여 게시하면 잘 바인딩되지만 urlencoding을 통해 게시 할 때는 @ModelAttribute에 문제가 있습니다. 문제가되는 게시물에 대한 내 몸에 대해 무엇입니까?
대량 문자 편집
firstName:JohnTest
lastName:Stafford
birthDate:1990-08-07
driversLicenseNumber:080005900
address:1700NW36thTerraceYukonOklahoma
zip:73099
email:[email protected]
homePhone:4055506800
workPhone:4055506800
amount:300
employer:meMyselfAndI
activeMilitary:0
incomeType:EMPLOYMENT
monthlyIncome:12000
date1:2016-12-02
date2:2016-12-16
frequency:TWICEMONTHLY
POST 는 x-WWW-formurlencoded에 사용컨트롤러 방법
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
public Lead save(@Valid @ModelAttribute("entity") final SampleEntity entity)
{
return createInternal(entity);
}
,363,210
SampleEntity는
@Entity
@Table(name="sample_table")
public class SampleEntity implements IBaseEntity{
/**
*
*/
private static final long serialVersionUID = -1110216193971231355L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "first_name")
@NotNull
private String firstName;
@Column(name = "last_name")
@NotNull
private String lastName;
@Column(name = "birth_date")
@NotNull
private String birthDate;
@Column(name = "drivers_license_number")
@NotNull
private String driversLicenseNumber;
@Column
@NotNull
private String address;
@Column
@NotNull
private String zip;
@Column
@NotNull
private String email;
@Column(name = "home_phone")
@NotNull
private String homePhone;
@Column(name = "work_phone")
@NotNull
private String workPhone;
@Column(name = "requested_amount")
@NotNull
private String requestedAmount;
@Column
@NotNull
private String employer;
@Column(name = "active_military")
@NotNull
private String activeMilitary;
@Column(name = "income_type")
@NotNull
private String incomeType;
@Column(name = "monthly_income")
@NotNull
private String monthlyIncome;
@Column
@Temporal(TemporalType.DATE)
@NotNull
private Date date1;
@Column
@Temporal(TemporalType.DATE)
@NotNull
private Date date2;
@Column(name = "frequency")
@NotNull
private String frequency;
//getters and setters
어떤 도움이 크게 감사합니다 (다시,이 응용 프로그램/json으로 POST 작동). 감사.
@InitBinder \t 공개 무효 initBinder 저장 공개 납 (WebDataBinder webDataBinder) { \t \t SimpleDateFormat의 자위대 = SimpleDateFormat의 새로운 ("YYYY-MM-DD"); \t \t webDataBinder.registerCustomEditor (Date.class, 새 CustomDateEditor (sdf, true)); \t} –