SSM中JSP和thymeleaf同时使用

在Spring—Mvc的xml文件中添加:

<!--    thymeleaf模板-->
    <bean id="templateResolver" class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
        <property name="prefix" value="/"/>
        <property name="suffix" value=".html"/>
        <property name="templateMode" value="HTML5" />
        <property name="cacheable" value="false" />
        <property name="characterEncoding" value="UTF-8"/>
    </bean>
    <!--thymeleaf4-->
    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
        <property name="templateResolver" ref="templateResolver" />
    </bean>

    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="viewResolvers">
            <list>
                <!--jsp-->
                <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="viewNames" value="behind/*"/>
                    <property name="prefix" value="/"/>
                    <property name="suffix" value=".jsp"/>
                </bean>
                <!--thymeleaf-->
                <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
                    <property name="viewNames" value="html/*"/>
                    <property name="characterEncoding" value="UTF-8"/>
                    <property name="templateEngine" ref="templateEngine" />
                    <property name="order" value="2" />
                </bean>
            </list>
        </property>
    </bean>

 

posted @ 2020-06-10 14:44  可达鸭给我冲鸭  阅读(870)  评论(0编辑  收藏  举报