簡體   English   中英

Hibernate的Spring Web Flow

[英]Spring Web Flow with Hibernate

漫長的谷歌后,我無法找到任何帶有休眠示例示例的Spring Web流。任何人都可以通過簡單的Spring Web流示例來幫助我。我需要使用Spring Web流創建一個登錄表單。到目前為止,我現在已經很熟悉Spring Web流。如果使用Hibernate連接到數據庫的任何示例應用程序(如登錄表單)會有所幫助。

如果無法找到示例代碼也不太困難,則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)。

集成Hibernate和Spring Web流程並非易事,這與Spring MVC相同。 只需編寫Hibernate配置文件即可。調用Service層,在服務層中僅調用各自的DAO。 DAO將與數據庫進行交互的位置。

您需要正常配置休眠屬性(使用引用表的@注釋等)。 不要忘記在DAO中添加“ @Service”注釋。 之后,您只需要轉到控制您的流程的xml文件,並添加DAO的功能即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM