Thyemleaf报错: Method call: Attempted to call method *** on null context object
翻译:方法调用:尝试在null上下文对象上调用方法***
解释:在Thyemleaf上下中不存在所要调用的对象,相当于Java代码中的NullPointerException
解决方案:
方案1. 需要将期望调用的java实例存入thymeleaf的context域中,代码层面即为:将实例对象存入Request对象中。
示例:
Java代码:
httpServletRequest.setAttribute("commons", commons);//一些工具类和公共方法
Thyemleaf表达式:
${commons.fmtdate_en(archive.created)}
方案2. thyemleaf表达式改变一下写法
${T(com.juyss.utils.Commons).fmtdate_en(archive.created)}
${T(要调用的类的全类名).要调用的方法}
Thyemleaf报错: Method call: Attempted to call method *** on null context object的更多相关文章
- java8 list转Map报错Collectors.toMap :: results in "Non-static method cannot be refernced from static context"
1.问题:java8 list转Map 报错Collectors.toMap :: results in "Non-static method cannot be refernced fro ...
- org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method test() on null context object
前言 本文中提到的解决方案,源码地址在:springboot-thymeleaf,希望可以帮你解决问题. 至于为什么已经写了一篇文章thymeleaf模板引擎调用java类中的方法,又多此一举的单独整 ...
- java实验三——求平均数,数组排序(有关java保留小数位数,由于编译器版本未到1.5导致的报错format函数第二个参数不对,要求是Object[])
package hello; import java.util.Arrays; public class 实验三更正版 { public static void main(String[] args) ...
- vue运行报错error:Cannot assign to read only property 'exports' of object '#<Object>'
用weex做项目的时候,npm start 之后一直报错error:Cannot assign to read only property 'exports' of object '#<Obje ...
- jpa报错 Unable to acquire a connection from driver [null], user [null] and URL [null]
jpa报错 Unable to acquire a connection from driver [null], user [null] and URL [null] 为啥报错 因为你在persist ...
- Spark报错java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
Spark 读取 JSON 文件时运行报错 java.io.IOException: Could not locate executable null\bin\winutils.exe in the ...
- 用apache-cxf生成webservice客户端的时候报错Parameter: shead already exists for method
版本apache-cxf-3.1.0 命令如下:wsdl2java -p com.wz.interfaces -d ./src -client ./ws/xxx.wsdl 报错如下: WSDLToJa ...
- ExtJs 4.2.1 报错:Uncaught TypeError: Cannot call method 'getItems' of null
做项目的时候遇到这个问题,搞了一上午终于解决了,让我们看看是什么问题: buttons: [ { text: '保存', icon: '../../../Images/extjs/disk.png', ...
- Feign调用远程服务报错:Caused by: java.lang.IllegalStateException: Method getMemberInfo not annotated with HTTP method type (ex. GET, POST)
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ord ...
- 【pheatmap热图scale报错】Error in hclust(d, method = method):NA/NaN/Inf in foreign function call (arg 11)
初始数据类似如下: 填充下缺失值 data[data==0] <- NA data[is.na(data)] <- min(data,na.rm = T)*0.01 pheatmap(lo ...
随机推荐
- Andrew BP 神经网络详细推导
Lec 4 BP神经网络详细推导 本篇博客主要记录一下Coursera上Andrew机器学习BP神经网络的前向传播算法和反向传播算法的具体过程及其详细推导.方便后面手撸一个BP神经网络. 目录 Lec ...
- Java8的新特性--并行流与串行流
目录 写在前面 Fork/Join框架 Fork/Join框架与传统线程池的区别 传统的线程池 Fork/Join框架 Fork/Join框架的使用 Java8中的并行流 写在前面 我们都知道,在开发 ...
- Android 系统开发做什么?
题外话 18 年我从 Android 应用开发转 Framework 层开发了,从此开启了 996 幸福生活,博客技术文更新基本停滞了,被工作占据了过多的精力,实在没时间像以前一样拟稿.写作,实践.反 ...
- PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642
PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642 题目描述: "单身狗"是中文对于单身人士的一种爱称.本题请你从上万人的大 ...
- Simulink中Scope数据保存至Workspace制图
0 问题 通常情况下,仿真模型中scope波形可编辑程度并不高,尽管高版本MATLAB中已经可以将其直接导出到figure,但效果并不是特别理想.在需要高质量输出波形图场合,就需要将其中数据导出到wo ...
- (十六)Struts2的标签库
一.简介 Struts2的标签库使用OGNL为基础,大大简化了数据的输出,也提供了大量标签来生成页面效果,功能非常强大. 在早期的web应用开发中,jsp页面主要使用jsp脚本来控制输出.jsp页面嵌 ...
- leetcode 刷题(数组篇)26题 删除有序数组中的重复值 (双指针)
题目描述 给你一个有序数组 nums ,请你 原地 删除重复出现的元素,使每个元素 只出现一次 ,返回删除后数组的新长度. 不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额 ...
- Spring Authorization Server 全新授权服务器整合使用
前言 Spring Authorization Server 是 Spring 团队最新开发适配 OAuth 协议的授权服务器项目,旨在替代原有的 Spring Security OAuth 经过半年 ...
- 【pytest官方文档】解读Skipping test functions,跳过测试用例详解
有时候,为了满足某些场景的需要,我们知道有些测试函数在这时候肯定不能执行,或者执行了也会失败.那么我们 可以选择去跳过这个测试函数,这样也就不会影响整体的测试函数运行效果,不至于在你运行的众多绿色通过 ...
- Linux 递归修改后缀名
1 修改命令 需要用到: find awk xargs 递归修改命令如下: find . -name '*.XXX' | awk -F "." '{print $2}' | xar ...