Spring MVC集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException
2024-09-05 12:04:11
错误提示:
defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.templateresolver.ServletContextTemplateResolver]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.thymeleaf.templateresolver.ServletContextTemplateResolver.<init>()
解决方法:
由于是从2.0版本升到3.0版本的原因,写法变了,应该在Bean上这样注入:
<!-- thymeleaf -->
<bean id="templateResolver" class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML" />
<property name="cacheable" value="false" />
</bean> <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean> <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<!--解决中文乱码-->
<property name="characterEncoding" value="UTF-8"/>
</bean>
参考:
最新文章
- Ural-1146Maximum Sum-最大子矩阵
- 苹果Mac OS X显示隐藏文件的方法
- php变量与数组相互转换的方法(extract与compact
- (转)MapReduce 中的两表 join 几种方案简介
- [CF787D]遗产(Legacy)-线段树-优化Dijkstra(内含数据生成器)
- thinkphp后台ajaxReturn提示下载的问题
- (六) Keras 模型保存和RNN简单应用
- react native中使用ScrollableTabView
- sudo命令 和限制root 远程登陆
- jq以固定开头的class属性的名称
- 5月23日——SPA单页面应用的原理
- iis部署wcf服务
- jmeter正则表达式提取器--关联
- python调用虹软2.0第三版
- Paket介绍
- Unity3D手机平台分辨率自动匹配教程
- Symfony 建立一个Bundle
- Python logger模块
- PHPredis长连接pconnect
- 【codeforces 1025E】Colored Cubes 【构造】