当前位置:网站首页>九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
2022-04-23 11:53:00 【托马斯-酷涛】
报错信息

2022-04-22 12:59:38.904 ERROR 16164 --- [nio-8888-exec-1] freemarker.runtime : Error executing FreeMarker template
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> pageContext [in template "courseAdd.html" at line 84, column 29]----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
--------
FTL stack trace ("~" means nesting-related):
- Failed at: ${pageContext.request.contextPath} [in template "courseAdd.html" at line 84, column 27]
----
后端代码

前端代码

其功能要实现下拉框,添加了option却显示不出来(如下图),并且后端数据已经拿到(打印在控制台了),心想就是前端这里拿不到数据。

回头看报错信息,发现
o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
大致意思为:Servlet请求处理失败,可能为空值或缺失值
问题分析
那应该就是空值的问题,导致下拉框无法正常显示,teacherNames中存在空值
看日志 给出了处理办法即(上方标红加粗的提示) 添加
<div class="layui-input-block">
<!-- <#if myOptionalVar??>when-present<#else>when-missing</#if>-->
<select id="baseCourseSelect" lay-search>
<option>--请选择——</option>
<#list teacherNames as tname>
<option value="${tname}">${tname}</option>
</#list>
</select>
</div>
后来通过查找找到了最终解决方法:
问题解决
在配置项(application.yml)中加入全局去空值的设置:
spring.freemarker.settings.classic_compatible= true

注意 true 前面有一个空格,不然不会生效。
最终效果

版权声明
本文为[托马斯-酷涛]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_54925305/article/details/124343229
边栏推荐
- 科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
- Castle.DynamicProxy实现事务单元控制
- How the database fills in IM expressions (IM 5.4)
- IDEA 数据库插件Database Navigator 插件
- 解读机器人创造出来的艺术
- QT 64 bit static version display gif
- 软银愿景基金进军Web3安全行业 领投CertiK 6000万美元新一轮投资
- qt5. 8. You want to use SQLite in the 64 bit static library, but the static library has no method to compile the supporting library
- 全网最细的短网址系统设计与实战
- IDEA 代码质量规范插件SonarLint
猜你喜欢

2022 love analysis · panoramic report of industrial Internet manufacturers

QT 64 bit static version display gif

Nacos Foundation (7): Configuration Management

Cognition and R & D technology of micro robot

rebbitMQ的简单搭建

IDEA 代码格式化插件Save Actions

SOFA Weekly | 年度优秀 Committer 、本周 Contributor、本周 QA

Simple construction of rebbitmq

Interpretation of 2022 robot education industry analysis report

C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
随机推荐
Blog post navigation (real-time update)
Chapter 4: enable and disable im column storage for materialized view (IM 4.6)
[Web 每日一练] 八色拼图(float)
创客教育中的统筹方案管理模式
力扣-1137.第N个泰波那契数
Tensorflow common functions
Laravel增加自定义助手函数
Interpretation of biological recognition in robot programming course
欣旺达宣布电池产品涨价 此前获“蔚小理”投资超10亿
The listing of saiweidian Technology Innovation Board broke: a decrease of 26% and the market value of the company was 4.4 billion
远程访问家里的树莓派(上)
Castle. Dynamic proxy implements transaction unit control
ES6学习笔记二
IM表达式如何工作(5.3)
golang之笔试题&面试题01
用户接口和IM表达式(IM 5.6)
ImportError: libX11.so.6: cannot open shared object file: No such file or directory
力扣-70.爬楼梯
第四章 为IM 启用填充对象之强制填充In-Memory对象:教程(IM 4.7)
Nacos Foundation (9): Nacos configuration management from single architecture to microservices