猿问

无法从 Thymeleaf 获取事务同步会话

我正在使用 SpringMVC,我的 jsp 页面没问题,但现在我尝试将我的应用程序与 Thymeleaf 集成。


thymeleaf-servlet.xml


<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:context="http://www.springframework.org/schema/context"

    xmlns:mvc="http://www.springframework.org/schema/mvc"

    xmlns:p="http://www.springframework.org/schema/p"

    xmlns:tx="http://www.springframework.org/schema/tx"

    xsi:schemaLocation="

        http://www.springframework.org/schema/beans

        http://www.springframework.org/schema/beans/spring-beans.xsd

        http://www.springframework.org/schema/context

        http://www.springframework.org/schema/context/spring-context-3.1.xsd

        http://www.springframework.org/schema/mvc

        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd

        ">


    <mvc:annotation-driven/>    

    <context:annotation-config />

    <context:component-scan base-package="com.application" />


    <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">

        <property name="prefix" value="/WEB-INF/thymeleaf/" />

        <property name="suffix" value=".html" />


    </bean>


    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">

        <property name="templateResolver" ref="templateResolver" />

    </bean>


    <bean id="viewResolver" class="org.thymeleaf.spring4.view.ThymeleafViewResolver">

        <property name="templateEngine" ref="templateEngine" />

    </bean>


    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">

        <property name="basenames">

            <!-- messages.properies -->

            <list><value>messages</value></list>

        </property>

    </bean>


千巷猫影
浏览 137回答 1
1回答

慕工程0101907

如果您的 productService 在方法上有 @Transactional,我猜您忘记在 xml 中添加事务注释<tx:annotation-driven&nbsp;/>请将上述元素添加到您的 xml
随时随地看视频慕课网APP

相关分类

Java
我要回答