【问题标题】:Spring Web Flow with Hibernate使用 Hibernate 的 Spring Web Flow
【发布时间】:2012-06-15 11:22:29
【问题描述】:

经过长时间的谷歌搜索后,我无法找到任何带有休眠示例示例的 Spring Web 流程。任何人都可以帮助我使用简单的 Spring Web 流程示例。我需要使用 Spring Web 流程创建一个登录表单。现在我还在熟悉 Spring Web 流程。如果任何示例应用程序(例如使用 Hibernate 连接到数据库的登录表单)将有所帮助。

【问题讨论】:

    标签: hibernate maven-3 spring-webflow


    【解决方案1】:

    如果您找不到示例代码,设置起来并不困难,SWF 只是一个控制器,在 Spring MVC 中注册为具有更多属性的控制器:

    <!-- Creates a flow executor in Spring, responsible for creating and executing flows -->
    <flow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
    
    <!-- Load flow definitions and make them available to the flow executor -->
    <flow:flow-registry id="flowRegistry">
        <flow:flow-location id="process-flow" path="/process/flows/process-flow.xml" />
    </flow:flow-registry>
    
    <!-- The FlowHandlerMapping helps DispatcherServlet to knowing that it should send flow requests to Spring Web Flow -->
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry" />
    </bean>
    
    <!-- The FlowHandlerAdapter is equivalent to a Spring MVC controller in that it handles requests coming in for a flow and processes those requests -->
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor" />
    </bean>
    

    一旦你有了 Hibernate,你就必须像使用任何其他 MVC 应用程序一样使用 Hibernate。也许您会对使用 FlowScoped PersistenceContext 感兴趣,它使 SWF 能够管理您的域对象 (http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/ch07s02.html)。

    考虑阅读 SWF 官方文档 (http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/index.html)。

    【讨论】:

      【解决方案2】:

      集成 Hibernate 和 Spring Web 流并不难。它和 Spring MVC 一样。只需编写Hibernate配置文件。调用服务层,在服务层调用相应的DAO。 DAO 将在哪里与数据库交互。

      【讨论】:

      • 这是对用户问题的一个较晚的回复,你应该试着用你的英语更清楚。
      【解决方案3】:

      您需要正常配置您的休眠属性(使用引用表的@ 注释等)。不要忘记在您的 DAO 中添加“@Service”注释。 之后,您只需要转到控制您的流程的 xml 文件,并添加 DAO 的功能。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-20
        • 2011-06-03
        • 1970-01-01
        • 2015-04-22
        • 1970-01-01
        相关资源
        最近更新 更多