小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

三大框架的整合技術(shù)

 zhangxiansen 2016-08-06

@三大框架整合的時候流程及注意事項,我們需要按照步驟來完成

步驟1:新建web項目;

步驟2:為項目添加spring的支持,

步驟3:在為項目添加hibernate的支持,這里我們不在使用hibernate.cfg.xml來管理sessionfactory,而是使用spring來對sessionFactory來進行管理

步驟4:導(dǎo)入struts的jar包支持,配置struts.Xml的配置文件,

步驟5:修改web.xml文件中的配置,首先為spring的配置文件添加監(jiān)聽,及初始化參數(shù)的配置,添加struts的攔截器,

步驟6:新建表 為表在項目中間添加映射文件使用xml的映射方式不要使用注解。

@配置具體的流圖及圖解:(圖片太小的自己放大)

開始:導(dǎo)入jar包(在后面的jar選擇中都不用勾了)

clip_image001clip_image005clip_image008

步驟一:新建一個項目,

clip_image010

clip_image012步驟二:添加spring的支持

clip_image013clip_image015

導(dǎo)入spring的jar包;

 

clip_image022

步驟三:添加hibernate的支持,用hibernate實現(xiàn)持久化,注意使用spring來對hibernate進行管理。

clip_image024clip_image031

clip_image033

clip_image035clip_image037

步驟四:在web怎樣告訴我們的spring來自動管理:在什么時候執(zhí)行了?我們在java項目中是通過調(diào)用ClassPathXmlApplicationContext (“spring的配置文件的存放位置”);返回一個BeanFactory工廠對象來解析指定的文件:然后調(diào)用getBean(“bean的名字”)來實例化bean;

//通過加載spring的配置文件
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
                
                //獲取配置文件中的bean實例
                UserManager userManager = (UserManager)factory.getBean("userManager");

在web項目中我們就需要在web.xml中配置監(jiān)聽來完成我們的spring的加載beanfactory工廠

 

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
        
        <!-- 指定applicationContext.xml的配置文件的位置 -->
        <!--如果這里的application。xml配置文件在src目錄下實例化參數(shù)應(yīng)該這么寫/WEB-INF/applicationContext.xml-->
        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
        </context-param>

 

步驟5:添加struts的配置,這里我是自己手動配置的,添加struts.xml文件在src目錄下

在web.xml中添加我struts攔截

 

                <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

 

這樣基本的配置完成。。代碼在我的文件中有上傳。三大框架整合.zip

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多