ile doğrulama çalışması yapılamıyor Bir form gösteren 1 denetleyicili bir Spring Boot uygulamasına (sürüm 1.2.3 kullanarak) sahibim. Bu her şey yolunda, ama şimdi validasyon eklemek istiyorum.Spring Boot ve Thymeleaf
@RequestMapping(value = "/licensing", method = RequestMethod.POST)
public String doRegistration(@Valid CustomerLicenseRegistration customerLicenseRegistration, Model model, BindingResult bindingResult)
{
if(bindingResult.hasErrors())
{
logger.debug("There are errors! {}", bindingResult);
return "customer/license-registration";
}
logger.debug("customerLicenseRegistration: " + customerLicenseRegistration);
CustomerLicense customerLicense = m_licenseService.createCustomerLicense(customerLicenseRegistration);
model.addAttribute("customerLicense", customerLicense);
return "customer/license-registration-done";
}
Şimdi geçersiz bir şey yazarsanız, ben "Whitelabel hata sayfası" olsun, sonra teslim ve ben @Valid
ek açıklama kaldırırsanız yönteme içinde benim kesme noktası (vurmak asla: benim denetleyicisi bu yöntemi var kesme noktası isabet alır).
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon May 18 09:42:27 CEST 2015
There was an unexpected error (type=Bad Request, status=400).
Validation failed for object='customerLicenseRegistration'. Error count: 1
Bahar nesne geçerli olmadığını fark gibi görünüyor, ancak kullanıcı hatasını düzeltmek böylece tekrar formu göstermiyor: hata sayfası gösterir. Neyi yanlış yapıyorum?
Cevap için teşekkürler dostum. Sorunun ne olduğunu anlamak için saatler koydum ve sadece yöntem imzası eşleşmesiyle geldi. Benim için çalış. Teşekkürler. :) – James
Thx. Cevabı beğendiyseniz lütfen çekin. –
emin. Sadece mutluluğu unuttum :) – James