当前位置:网站首页>九十八、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
边栏推荐
- tensorflow常用的函数
- Chapter 4 is a tutorial on forced filling of in memory objects with IM enabled filling objects (IM 4.7)
- Link sorting of tutorials such as assembly language running environment setting
- Compress the curl library into a sending string of utf8 and send it with curl library
- Practical data Lake iceberg lesson 30 MySQL - > iceberg, time zone problems of different clients
- Golang's pen test questions & interview questions 01
- 数据库如何填充IM表达式(IM 5.4)
- 科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
- Redis optimization series (II) redis master-slave principle and master-slave common configuration
- Database design of simple voting system
猜你喜欢

解读2022机器人教育产业分析报告

积极参与中学机器人竞赛的意义

WIN10 启动后花屏

5个免费音频素材网站,建议收藏
![Study notes of C [8] SQL [1]](/img/b3/cb684f3ee14cc4e313be217320d5d6.png)
Study notes of C [8] SQL [1]

MQ在laravel中简单使用

Nacos Foundation (8): login management

VMware虚拟机使用esxi 导出硬盘vmdk文件

Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?

Analyze the rules for the use of robots with good performance
随机推荐
Force buckle - 1137 Nth teponacci number
Interpretation of 2022 robot education industry analysis report
Redis学习之五---高并发分布式锁实战
How to count fixed assets and how to generate an asset count report with one click
Chapter 5 optimizing queries using in memory expressions (IM 5.1)
魔域来了H5游戏详细图文架设教程
Significance of actively participating in middle school robot competition
1.Electron开发环境搭建
怎么进行固定资产盘点,资产盘点报告如何一键生成
Laravel adds custom helper functions
Relu function of activation function
Study notes of C [8] SQL [1]
博客文章导航(实时更新)
C# F23.StringSimilarity库 字符串重复度、文本相似度、防抄袭
力扣-70.爬楼梯
NativeForMySQL 连接MySQL8 提示:1251- Client does not support authentication protocol
Application of remote integrated monitoring system in power distribution room in 10kV prefabricated cabin project
IDEA 代码质量规范插件SonarLint
Use kettle to copy records to and get records from results
解读机器人创造出来的艺术