首页 > 其他 > 详细

【其他】【freemarker】【1】遇到的问题

时间:2019-05-26 23:37:51      阅读:176      评论:0      收藏:0      [点我收藏+]

前言:

1,空值导致页面报异常,Error executing FreeMarker template,The following has evaluated to null or missing

 

正文:

1,空值导致页面报异常,Error executing FreeMarker template,The following has evaluated to null or missing

原因:页面存在判断条件<#if user>,当user不存在时则报错。需写为<#if user??>,或者更改后端的FreeMarker配置。

注:我使用的时候是更改配置没有生效,还是要前端再做控制,这里写出来仅做参考

<!-- FreeMarker配置 -->
<bean id="freemarkerConfig"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/template/" />
        <property name="freemarkerSettings">
            <props>                
                <prop key="classic_compatible">true</prop><!--用于解决前端报空指针问题-->
                <prop key="defaultEncoding">utf-8</prop><!-- 设置默认的编码方式,原先是GBK,需要设置成utf-8 -->
                <prop key="template_exception_handler">rethrow</prop>
            </props>
        </property>
    </bean>

参考博客:

freemarker的classic_compatible设置,解决报空错误 - Weagle - 博客园
https://www.cnblogs.com/Weagle/p/5417947.html

【其他】【freemarker】【1】遇到的问题

原文:https://www.cnblogs.com/huashengweilong/p/10924916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!