日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

Spring學習基礎(chǔ)---配置文件(2)_JSP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:Spring學習基礎(chǔ)---多框架集成
ApplicationContextctx 1,定義資源文件獲得資源文件的消息,國際化信息 beanid=messageResourceclass=org.springFramework.context.support.ResourceBoundleMessageSource propertyname=basenames xxxx /property /bean 將會搜索xxxx.properties,xxxx_


5,配置文件中定義dataSource
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="${jdbc.driverClassName}"/>
  <property name="url" value="${jdbc.url}"/>
  <property name="username" value="${jdbc.username}"/>
  <property name="password" value="${jdbc.password}"/>
 </bean>
 可見,可以直接使用properties中的key。另外可以將數(shù)據(jù)庫操作弄成另外一個配置文件。只要在web.xml中設(shè)置好就可以了,
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
   /WEB-INF/dataAccessContext-local.xml  /WEB-INF/applicationContext.xml
  </param-value>
 </context-param>

6,配置文件中定義事務(wù)管理
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource"/>
 </bean>
 使用了數(shù)據(jù)源作為屬性。

7,dao具體實現(xiàn)類。
 JPetStore使用ibatis作為ORM層。所以dao類的定義也都使用了ibatis。
 PetStoreImpl五個接口接受五個實現(xiàn)了對應(yīng)接口的實現(xiàn)類。這里的實現(xiàn)類,
<bean id="petStore" class="org.springframework.samples.jpetstore.domain.logic.PetStoreImpl">
  <property name="accountDao" ref="accountDao"/>
  <property name="categoryDao" ref="categoryDao"/>
  <property name="productDao" ref="productDao"/>
  <property name="itemDao" ref="itemDao"/>
  <property name="orderDao" ref="orderDao"/>
 </bean>
 <bean id="accountDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 實現(xiàn)類,使用ibatis。在配置文件中對英。
public class SqlMapAccountDao extends SqlMapClientDaoSupport implements AccountDao{
 //實現(xiàn)了業(yè)務(wù)接口,繼承了ibatis基本類。
 }

8,ibatis基礎(chǔ)類。
    <!-- SqlMap setup for iBATIS Database Layer -->
 <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
  <property name="dataSource" ref="dataSource"/>
 </bean>
 dao實現(xiàn)類都由他作屬性。
    <bean id="accountDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>

9,我竟然找不到action對應(yīng)的mapping在什么地方定義的。
后來找到了是petstore-servlet.xml,by default defined in "{servlet-name}-servlet.xml"...
<!--
   - Spring web MVC servlet that dispatches requests to registered handlers.
   - Has its own application context, by default defined in "{servlet-name}-servlet.xml",
   - i.e. "petstore-servlet.xml" in this case.
   -
   - A web app can contain any number of such servlets.
   - Note that this web app has a shared root application context, serving as parent
   - of all DispatcherServlet contexts.
   -->
 <servlet>
  <servlet-name>petstore</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>2</load-on-startup>
 </servlet>
 原來是根據(jù)servlet名字命名影射文件的。
 影射文件和配置文件的結(jié)構(gòu)完全一致,也是beans開頭的。主要是web層的url影射,
 <beans>
 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
  <property name="prefix" value="/WEB-INF/jsp/spring/"/>
  <property name="suffix" value=".jsp"/>
 </bean>
 ....
 </beans>
 ok,現(xiàn)在把petstore-servlet.xml也放到SpringIDE里察看。

分享:JSP初級教程之跟我學JSP(八)
第八章Blob類型數(shù)據(jù)的存取和使用第一個Servlet—— 圖片文件的操作 以下是我經(jīng)過改編得到的 jsp 代碼: ------------------------------upphoto.htm------------------------------------ html head metahttp-equiv=Content-Typecontent=text/html;charse

來源:模板無憂//所屬分類:JSP教程/更新時間:2010-03-08
相關(guān)JSP教程