跟我一起學extjs5(27--服務端web,spring,hibernate設定檔的加入)

來源:互聯網
上載者:User

跟我一起學extjs5(27--服務端web,spring,hibernate設定檔的加入)
跟我一起學extjs5(27--服務端web,spring,hibernate設定檔的加入)

我們前面建立項目的時候是一個java web project,現在在項目中需要加入spring,hibernate,sqlserver串連的jar包以及加入設定檔。spring我現在使用的是3.1版本,hibernate使用的是3.0,具體的jar包以及一些附加元件封裝,請自行下載後加到工程中。(所有的jar包在我的前一個部落格中提供的示範軟體中有)
一、在java Resources的src中加入一些package。在src目錄下建立檔案hibernate.cfg.xml和log4j.properties。

hibenate的設定檔如下:/application5.01/src/hibernate.cfg.xml (使用的是sql server資料庫,用其他資料庫也可以。)
com.microsoft.sqlserver.jdbc.SQLServerDriverjdbc:sqlserver://10.211.55.5:1433;databaseName=haiyuorg.hibernate.dialect.SQLServerDialectsafalsetruetrue

系統日誌設定檔:/application5.01/src/log4j.properties 。
log4j.rootCategory=error, consolelog4j.appender.console=org.apache.log4j.ConsoleAppenderlog4j.appender.console.layout=org.apache.log4j.PatternLayoutlog4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%nlog4j.logger.org.hibernate=errorlog4j.logger.org.hibernate.SQL=errorlog4j.logger.com.jfok=errorlog4j.logger.org.springframework=error#log4j.category.org.hibernate.type=debug

二、修改web.xml檔案,加入spring的設定。 在WEB-INF目錄下需要修改web.xml ,並加入二個spring 的設定檔applicationContext.xml和dispatcherServlet-servlet.xml。

web.xml的檔案內容:
org.springframework.web.context.ContextLoaderListenerContextConfigLocation/WEB-INF/applicationContext.xmldispatcherServletorg.springframework.web.servlet.DispatcherServlet1dispatcherServlet*.do/rest/*encodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8forceEncodingtrueencodingFilter/*/index.jsp180*.jsptrue

applicationContext.xml的內容:

 

dispatcherServlet-servlet.xml的內容:
 (由於使用的spring的annotation註解進行開發,因此設定檔在以後開發過程中基本上不用修改。)
 
三、將index.html改名為index.jsp。
四、在tomcat中發布此工程。如果運行時沒有出錯資訊,則說明所有的配置和jar包都正確了。
五、在瀏覽器中輸入網址:http://localhost:8888/app/,應該顯示原來做過的頁面。vc 也只是用做一個簡單的設定檔並且用標註語言來進行開發,對於這方面比較深的問題我也不會,如果搭建過程中有問題,請盡量自行解決。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.