Exception evaluating SpringEL expression: “#fields.hasErrors()“ (template
今天学习spring实战第5版,里面有一些小错误,代码如下:
// tag::all[]
// tag::allButValidation[]
package tacos;import java.util.List;
// end::allButValidation[]import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;// tag::allButValidation[]
import lombok.Data;@Data
public class Taco {// end::allButValidation[]// tag::allButValidation[]// @Size(min=5,message = "至少五个字符")@NotEmpty(message = "不能为空")private String name;// end::allButValidation[]// tag::allButValidation[]@Size(min = 1, message = "至少选择一个配料")private List<String> ingredients;}
//end::allButValidation[]
//tag::end[]
DesignTacoController的请求如下:
注意我们的实体类其实叫Taco,而教材为model添加的键为design
前端也一样,通过thymeleaf获取了design
上图为接收表单的post请求,把表单的name作为空值提交,这样通过validation检查就会报错,从而返回design,而在design页面就会报错
提示已经很明显了,该name属性不存在于design。
解决方式如下,将get请求的键改为taco,还有不要忘记前端的form里的th:Object也改为taco
所以个人认为,如果实体类需要添加校检,get请求的键值名称要和实体类名字一致。
解决如下图:
Exception evaluating SpringEL expression: “#fields.hasErrors()“ (template相关推荐
- BUG记录: Exception evaluating SpringEL expression
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expre ...
- BUG记录:Exception evaluating SpringEL expression
完整错误信息 2022-11-28 16:24:47 ERROR (TemplateEngine.java:1136)- [THYMELEAF][http-nio-8080-exec-4] Excep ...
- Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expre
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expre ...
- Thymeleaf中使用select进行消息回显时提示:Exception evaluaating SpringEL expression
场景 在进行新增和编辑共用一个页面时,选择新增则页面没有refundOrder传值, 选择编辑择有. 使用thymeleaf进行select的下拉选中的回显时提示: 错误代码如下: <selec ...
- SpringEL expression:
2019独角兽企业重金招聘Python工程师标准>>> 这个异常有下面几种情况 1.你写的 EL 表达式有语法错误. 2.再者就是你取得变量是多级的话比如 student.addre ...
- thymeleaf.TemplateEngineException processing template “main“: An error happened during template pars
前言 这个项目是springboot 项目使用thymeleaf模板的,主要错误是前端HTML页面使用thymeleaf获取后台传过来的值有问题(获取不到,或者为空null) 错误信息 1.第一个错误 ...
- thymeleaf 异常:SpelEvaluationException: EL1008E: Property or field ‘url‘ cannot be found
前言 thymeleaf页面遇错如下: Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expressi ...
- 使用thymeleaf对数据库取出的数据进行渲染时所踩的”坑“
报错: Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "activi ...
- Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1030E: The operator 'SUBTR
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1030E: The operator 'SUBTR ...
最新文章
- 漫画 | Nature审了个稿,却卷进一桩诺贝尔奖的公案!
- php代码冗余度检查插件,合并ThinkPHP配置文件以消除代码冗余的实现方法
- 深入浅出 SpringMVC - 2 提升篇
- 安装archlinux_archlinux/manjaro 上安装percona-server
- 荷小鱼 x mPaaS | 借助 H5 容器改善 App 白屏、浏览器兼容问题
- pc端文本_使用即将推出的Windows功能从PC发送文本
- idea创建web项目运行报404错误_使用IDEA新建Web工程启动报404的错误
- Spring事务如何集成到Mybatis之springboot事务
- Eclipse+Maven创建webapp项目二 (转)
- 让系统自动登录的方法
- 第九章(二)DAG上的动态规划
- c++ 写ftp服务器文件,C++实现的FTP服务器
- u盘读写速度变慢了开始快后面特别慢卡顿解决方法
- Selenium+超级鹰进行识别滑动操作
- Vue项目:style样式篇
- 中恒建模助手插件和绿色建筑的完美结合
- 《Caffe Modle Zoo》
- 涨姿势!3D游戏里的男女性角色是这样建模出来的
- RFC5869翻译 HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
- 处理 yarn 项目 has unmet peer dependency