zoukankan      html  css  js  c++  java
  • Spring MVC集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException

    错误提示:

    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>

    参考:

    https://stackoverflow.com/questions/38057341/failed-to-instantiate-org-thymeleaf-templateresolver-servletcontexttemplatereso

  • 相关阅读:
    C#里partial关键字的作用
    Xamarin.Android之布局文件智能提示问题
    C语言文件操作
    CArray
    Unicode和多字节的相互转换
    可变参数问题研究
    VC6.0支持UNICODE的步骤
    Unicode编码表
    @@
    内存映射文件原理
  • 原文地址:https://www.cnblogs.com/EasonJim/p/7519817.html
Copyright © 2011-2022 走看看