配置Thymeleaf 3.1.1视图解析器(Spring6 + SpringMVC 6 + Tomcat10 + JDK17)

   <!-- SpringResourceTemplateResolver automatically integrates with Spring's own -->
    <!-- resource resolution infrastructure, which is highly recommended.          -->
    <bean id="templateResolver"
          class="org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver">
        <property name="prefix" value="/WEB-INF/templates/" />
        <property name="suffix" value=".html" />
        <!-- HTML is the default value, added here for the sake of clarity.          -->
        <property name="templateMode" value="HTML" />
        <!-- Template cache is true by default. Set to false if you want             -->
        <!-- templates to be automatically updated when modified.                    -->
        <property name="cacheable" value="true" />

        <property name="characterEncoding" value="UTF-8" />
    </bean>

    <!-- SpringTemplateEngine automatically applies SpringStandardDialect and      -->
    <!-- enables Spring's own MessageSource message resolution mechanisms.         -->
    <bean id="templateEngine"
          class="org.thymeleaf.spring6.SpringTemplateEngine">
        <property name="templateResolver" ref="templateResolver" />
        <!-- Enabling the SpringEL compiler can speed up execution in most           -->
        <!-- scenarios, but might be incompatible with specific cases when           -->
        <!-- expressions in one template are reused across different data types, so  -->
        <!-- this flag is "false" by default for safer backwards compatibility.      -->
        <property name="enableSpringELCompiler" value="true" />
    </bean>

    <bean class="org.thymeleaf.spring6.view.ThymeleafViewResolver">
        <property name="templateEngine" ref="templateEngine" />
        <!-- NOTE 'order' and 'viewNames' are optional -->
        <property name="order" value="1" />
<!--        <property name="viewNames" value="*.html,*.xhtml" />-->
        <property name="characterEncoding" value="UTF-8"/>
    </bean>

Thymeleaf在使用最新版本的框架时(Spring6 + SpringMVC 6 + Tomcat10 + JDK17 ),出现各种500错误,配置.xml

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值