HTTP Status 500 - Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 3 errors
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 3 errors Field error in object ‘league‘ on field ‘season‘: rejected value []; codes [NotBlank.league.season,NotBlank.season,NotBlank.java.lang.String,NotBlank]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [league.season,season]; arguments []; default message [season]]; default message [季节不能为空] Field error in object ‘league‘ on field ‘year‘: rejected value [null]; codes [NotNull.league.year,NotNull.year,NotNull.java.lang.Integer,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [league.year,year]; arguments []; default message [year]]; default message [年份不能为空] Field error in object ‘league‘ on field ‘title‘: rejected value []; codes [Length.league.title,Length.title,Length.java.lang.String,Length]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [league.title,title]; arguments []; default message [title],20,4]; default message [长度应在4-20个字符之间] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) javax.servlet.http.HttpServlet.service(HttpServlet.java:647) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
问题是控制器类的方法里边加了一个无用的参数:Model model.去掉该参数后恢复正常。
可能的原因:
1.由于表单的字段值填的不合要求。
2.方法的参数中有model,SpringMVC试图将表单中的参数封装成对象,造成错误。
时间: 2024-10-09 19:51:37