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 ...
随机推荐
- python爬取考研专业信息
伴随着2021考研成绩的公布,2021考研国家线也即将到来.大家是否有过考研的想法了?如果想考研我们就需要了解很多的信息,但是百度的上有太多信息需要我们去一一的鉴别,是比较浪费时间的.所以我们可以学习 ...
- python基础学习之类的继承、魔法方法
什么是继承 即类A可以使用类B的方法,即B是A的父类,A是B的子类,AB之间是继承关系 class Father(): # 父类 def __init__(self,name,age): self. ...
- Docker 一图胜千言
Docker 一图胜千言 0 为什么 Docker 比虚拟机快? 注:少了一层抽象层( Hypervisor ) 1 Docker Logo 要素: 大海 宿主机 Host 鲸鱼 Docker 集装箱 ...
- PTE 准备之 Read aloud
Read aloud A text appears on screen.Read the text aloud rext up tp 60 words varies by task, dependin ...
- JAVA常用的集合转换
在Java应用中进行集合对象间的转换是非常常见的事情,有时候在处理某些任务时选择一种好的数据结构往往会起到事半功倍的作用,因此熟悉每种数据结构并知道其特点对于程序员来说是非常重要的,而只知道这些是不够 ...
- 《逆向工程核心原理》——DLL注入与卸载
利用CreateRemoteThread #include <iostream> #include <tchar.h> #include <Windows.h> # ...
- gstreamer应用开发(播放器)之旅
GStreamer开发,主要分为两块:应用开发.插件开发. 插件开发人员,通常是编解码库的作者(做出了编解码库后,希望gstreamer能用起来这个库,因此增加这个适配层).芯片原厂人员(将自家的hw ...
- 微信小程序--简约风博客小程序(基于云开发 - 全开源)
微信小程序--简约风博客小程序(基于云开发 - 全开源) 项目启动纯属突发奇想,想看看博客小程序,例如wehalo博客小程序,但是感觉自建平台还要浪费自己的服务器算力,还没有访问量,省省吧. 本着白嫖 ...
- 力扣 - 347. 前 K 个高频元素
目录 题目 思路1(哈希表与排序) 代码 复杂度分析 思路2(建堆) 代码 复杂度分析 题目 347. 前 K 个高频元素 思路1(哈希表与排序) 先用哈希表记录所有的值出现的次数 然后将按照出现的次 ...
- 用 customRef 做一个防抖函数,支持 element 等UI库。
这几天学习Vue的官网,看到 customRef 提供了一个例子,研究半天发现这是一个防抖函数,觉得挺好,于是把这个例子扩展了一下,可以用于表单子控件和查询子控件. 需求 v-model 基于 ele ...