隨筆-295  評論-26  文章-1  trackbacks-0
           

          <%@ taglib uri="

          <c:redirect url="home.htm"/>
          <c:redirect url="b.jsp">
          <c:param name="data" value="jsp_passdata中文傳值"></c:param>
          </c:redirect>

          他們兩個作用相似
          <jsp:forward page="/utils/errorReporter.jsp"/>

          <jsp:forward page="/test4.jsp">
          <jsp:param name="name" value="powerman"/>
          <jsp:param name="address" value=" 北京西大街188號"/>
          </jsp:forward>

          <fmt:requestEncoding value="big5"/>
          

          Spring-mvc 的處理流程

          關(guān)鍵字: Spring ? mvc ioc ????

          請求的分發(fā)

          請求首先到達DispatcherServlet,應(yīng)用服務(wù)器會根據(jù)Web應(yīng)用中web.xml文件定義的url映射將相應(yīng)的請求分發(fā)到DispatcherServlet中

          請求的處理

          DispatcherServlet會查找相應(yīng)的HandlerMapping接口的實現(xiàn)類,調(diào)用其中的方法:HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception,該方法會返回一個HandlerExecutionChain。返回的HandlerExecutionChain中包含了零個或者是多個Interceptor和一個處理請求的Handler。DispatcherServlet會調(diào)用Interceptor中的preHandle() 方法。然后處理Handler,這個Handler相當于Struts中Action,在SpringMVC中默認的實現(xiàn)是Controller接口,是具體處理請求的代碼所駐留的地方。事實上HandlerExecutionChain中的getHandler()返回的是一個Object類型。DispatcherServlet不會直接調(diào)用getHandler()返回對象中的方法,DispatcherServlet會查找相應(yīng)的HandlerAdapter,然后具體通過HandlerAdapter來調(diào)用getHandler()返回的handler對象中的方法。就是說我們可以實現(xiàn)自己的HandlerAdapter然后通過IoC注入到DispatcherServlet中,從而可以實現(xiàn)一套自定義的控制器。隨后DispatcherServlet會調(diào)用Interceptor中的postHandle()方法。

          視圖的處理

          DispatcherServlet會期望Hander返回一個ModelAndView,DispatcherServlet會根據(jù)所返回的ModelAndView對象所包含的信息進行視圖的渲染。起具體出來流程如下:

          首先DispatcherServlet會根據(jù)LocaleResolver來識別請求中的Locale,開發(fā)人員可以自己實現(xiàn)LocaleResolver接口,然后通過IoC注入到DispatcherServlet中,然后DispatcherServlet會判斷ModelAndView中是否已經(jīng)包含了接口View的具體實現(xiàn),如果包含了,則直接調(diào)用View中的方法render(Map model, HttpServletRequest request, HttpServletResponse response)。如果不包含,則說明該ModelAndView只是包含了View的名稱引用,DispatcherServlet會調(diào)用ViewResolver中的resolveViewName(String viewName, Locale locale)來解析其真正的視圖。該方法會返回一個View的具體實現(xiàn)。

          視圖的渲染

          Spring支持多種視圖技術(shù),其中比較常用的包括有Jstl視圖,Veloctiy視圖,F(xiàn)reeMarker視圖等。對Jstl視圖的渲染Spring是通過JstlView這個類具體實現(xiàn)的。事實上其最終的渲染是交給容器來做的,Spring只是通過RequestDispatcher實現(xiàn)了服務(wù)器內(nèi)部請求的Forward。而對于模板視圖,如Veloctiy和FreeMarker等,Spring會初始化其相應(yīng)的模板引擎,由模板引擎生成最終的Html頁面然后在合并到Response的輸出流中。

          異常的處理

          如果在Hander中處理請求是拋出異常,DispatcherServlet會查找HandlerExceptionResolver接口的具體實現(xiàn),該接口定義了一個方法:

          ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex),實現(xiàn)類需要實現(xiàn)該方法以便對異常進行處理,最后該方法需要返回一個ModelAndView。

          SpringMVC的一些總結(jié)
          靈活的Interceptor,通過Interceptor我們可以在一個請求處理前和請求處理完成之后做相應(yīng)的操作,通過Interceptor機制,我們可以做authentication, logging, and filtering等。
          良好的表單支持,在SpringMVC的Controller繼承體系結(jié)構(gòu)中,其具體的子類對表單(Form)提供了良好的支持。能夠很好的支持單個表單的顯示、修改、提交操作。同時也提供了表單的分步提交。
          可定制的數(shù)據(jù)綁定(Data Binding)。
          多視圖技術(shù)的支持,SpringMVC同時支持Jstl, Velocity 等多中視圖技術(shù),但是這同時也會引出一個問題,因為各種視圖技術(shù)都有自己的一套方法來處理國際化,例如Jstl和Velocity處理國際化的方式就很不相同。因此在多個視圖技術(shù)并存的應(yīng)用中,國際化也是一個需要注意的問題。
          其Handler(控制器)作為Bean定義在Spring容器中,因此能享受容器帶來的服務(wù)。
          Handler(控制器)具有良好的可測試性。

          posted @ 2007-08-29 10:23 華夢行 閱讀(2957) | 評論 (0)編輯 收藏
          public abstract class HttpServletBean
          extends HttpServlet
          		

          Simple extension of HttpServlet which treats its config parameters (init-param entries within the servlet tag in web.xml) as bean properties.

          HttpServlet的簡單擴展用來處理 (init-param)in the web.xml
          A handy superclass for any type of servlet. Type conversion of config parameters is automatic, with the corresponding setter method getting invoked with the converted value. It is also possible for subclasses to specify required properties. Parameters without matching bean property setter will simply be ignored.

          This servlet leaves request handling to subclasses, inheriting the default behavior of HttpServlet (doGet, doPost, etc).

          This generic servlet base class has no dependency on the Spring ApplicationContext concept. Simple servlets usually don't load their own context but rather access service beans from the Spring root application context, accessible via the filter's ServletContext (see WebApplicationContextUtils).

          The FrameworkServlet class is a more specific servlet base class which loads its own application context. FrameworkServlet serves as direct base class of Spring's full-fledged DispatcherServlet.

          public abstract class FrameworkServlet
          extends HttpServletBean
          implements ApplicationListener
          		

          Base servlet for Spring's web framework. Provides integration with a Spring application context, in a JavaBean-based overall solution.

          spring web Framework的基礎(chǔ) servlet? ,提供在以javabean為基礎(chǔ)的整體解決方案已完成與spring應(yīng)用上下文的集成
          This class offers the following functionality:
          1.管理一個servlet一個網(wǎng)絡(luò)應(yīng)用上下文實例,這個servlet的配置由servlet命名空間里的bean來決定
          2.根據(jù)請求處理發(fā)布事件,是否請求成功的被處理了

          • Manages a WebApplicationContext instance per servlet. The servlet's configuration is determined by beans in the servlet's namespace.
          • Publishes events on request processing, whether or not a request is successfully handled.

          Subclasses must implement doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) to handle requests. Because this extends HttpServletBean rather than HttpServlet directly, bean properties are automatically mapped onto it. Subclasses can override initFrameworkServlet() for custom initialization.

          因為它繼承自httpservletBean 所以bean的屬性已經(jīng)被自動的裝配了,子類可以通過覆蓋initFrameworkServlet來定制初始化bean

          Detects a "contextClass" parameter at the servlet init-param level, falling back to the default context class, XmlWebApplicationContext, if not found. Note that, with the default FrameworkServlet, a custom context class needs to implement the ConfigurableWebApplicationContext SPI.

          Passes a "contextConfigLocation" servlet init-param to the context instance, parsing it into potentially multiple file paths which can be separated by any number of commas and spaces, like "test-servlet.xml, myServlet.xml". If not explicitly specified, the context implementation is supposed to build a default location from the namespace of the servlet.

          Note: In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files, at least when using Spring's default ApplicationContext implementation. This can be leveraged to deliberately override certain bean definitions via an extra XML file.

          The default namespace is "'servlet-name'-servlet", e.g. "test-servlet" for a servlet-name "test" (leading to a "/WEB-INF/test-servlet.xml" default location with XmlWebApplicationContext). The namespace can also be set explicitly via the "namespace" servlet init-param.

          posted @ 2007-08-29 10:13 華夢行 閱讀(681) | 評論 (0)編輯 收藏
          HeidiSQL
          posted @ 2007-08-28 15:54 華夢行 閱讀(125) | 評論 (0)編輯 收藏
          				
          <bean id="exampleInitBean" class="examples.ExampleBean" init-method="cleanup"/>

          <bean id="exampleInitBean" class="examples.ExampleBean" destroy-method="cleanup"/>
          posted @ 2007-08-28 14:28 華夢行 閱讀(174) | 評論 (0)編輯 收藏
          Bean factory implementations should support the standard bean lifecycle interfaces as far as possible. The full set of initialization methods and their standard order is:
          BeanFactory的實現(xiàn)應(yīng)該盡可能支持標準的bean生命周期,以下是所以的方法的順序的依次列表
          1. BeanNameAware's?? setBeanName
          2. BeanClassLoaderAware's? setBeanClassLoader
          3. BeanFactoryAware's?? setBeanFactory
          4. ResourceLoaderAware's setResourceLoader (only applicable when running in an application context)
          5. ApplicationEventPublisherAware's setApplicationEventPublisher (only applicable when running in an application context)
          6. MessageSourceAware's setMessageSource (only applicable when running in an application context)
          7. ApplicationContextAware's setApplicationContext (only applicable when running in an application context)
          8. ServletContextAware's setServletContext (only applicable when running in a web application context)
          9. postProcessBeforeInitialization methods of BeanPostProcessors
          10. InitializingBean's afterPropertiesSet
          11. a custom init-method definition
          12. postProcessAfterInitialization methods of BeanPostProcessors
          ?當關(guān)閉一個bean的時候
          On shutdown of a bean factory, the following lifecycle methods apply:
          1. DisposableBean's destroy
          2. a custom destroy-method definition

          Method Summary
          ?booleancontainsBean(String?name)
          ??????????Does this bean factory contain a bean with the given name?
          ?String[]getAliases(String?name)
          ??????????Return the aliases for the given bean name, if any.
          ?ObjectgetBean(String?name)
          ??????????Return an instance, which may be shared or independent, of the specified bean.
          ?ObjectgetBean(String?name, Class?requiredType)
          ??????????Return an instance, which may be shared or independent, of the specified bean.
          ?ClassgetType(String?name)
          ??????????Determine the type of the bean with the given name.
          ?booleanisPrototype(String?name)
          ??????????Is this bean a prototype?
          ?booleanisSingleton(String?name)
          ??????????Is this bean a shared singleton?
          ?booleanisTypeMatch(String?name, Class?targetType)
          ??????????Check whether the bean with the given name matches the specified type.
          ?
          posted @ 2007-08-28 14:09 華夢行 閱讀(569) | 評論 (0)編輯 收藏
          public interface Lifecycle
          		

          Interface defining methods for start/stop lifecycle control. The typical use case for this is to control asynchronous processing.

          Can be implemented by both components (typically a Spring bean defined in a Spring BeanFactory) and containers (typically a Spring ApplicationContext). Containers will propagate start/stop signals to all components that apply.

          Can be used for direct invocations or for management operations via JMX. In the latter case, the MBeanExporter will typically be defined with an InterfaceBasedMBeanInfoAssembler, restricting the visibility of activity-controlled components to the Lifecycle interface.

          Since:
          2.0
          Author:
          Juergen Hoeller
          See Also:
          ConfigurableApplicationContext , AbstractMessageListenerContainer, SchedulerFactoryBean

          Method Summary
          ?boolean isRunning ()
          ??????????Check whether this component is currently running.
          ?void start ()
          ??????????Start this component.
          ?void stop ()
          ??????????Stop this component.
          ?
          posted @ 2007-08-28 13:49 華夢行 閱讀(158) | 評論 (0)編輯 收藏
          Spring中Bean的生命周期
          ? ? 在傳統(tǒng)的Java應(yīng)用中,Bean的生命周期非常簡單。Java的關(guān)鍵詞new用來實例化Bean(或許他是非序列化的)。這樣就夠用了。相反,Bean的生命周期在Spring容器中更加細致。理解Spring Bean的生命周期非常重要,因為你或許要利用Spring提供的機會來訂制Bean的創(chuàng)建過程。


          1. 容器尋找Bean的定義信息并且將其實例化。
          2.受用依賴注入,Spring按照Bean定義信息配置Bean的所有屬性。
          3.如果Bean實現(xiàn)了BeanNameAware接口,工廠調(diào)用Bean的setBeanName()方法傳遞Bean的ID。
          4.如果Bean實現(xiàn)了BeanFactoryAware接口,工廠調(diào)用setBeanFactory()方法傳入工廠自身。
          5.如果BeanPostProcessor和Bean關(guān)聯(lián),那么它們的postProcessBeforeInitialzation()方法將被調(diào)用。
          6.如果Bean指定了init-method方法,它將被調(diào)用。
          7.最后,如果有BeanPsotProcessor和Bean關(guān)聯(lián),那么它們的postProcessAfterInitialization()方法將被調(diào)用。
          ??? 到這個時候,Bean已經(jīng)可以被應(yīng)用系統(tǒng)使用了,并且將被保留在Bean Factory中知道它不再需要。有兩種方法可以把它從Bean Factory中刪除掉。
          1.如果Bean實現(xiàn)了DisposableBean接口,destory()方法被調(diào)用。
          2.如果指定了訂制的銷毀方法,就調(diào)用這個方法。
          ??? Bean在Spring應(yīng)用上下文的生命周期與在Bean工廠中的生命周期只有一點不同,唯一不同的是,如果Bean實現(xiàn)了ApplicationContextAwre接口,setApplicationContext()方法被調(diào)用。

          posted @ 2007-08-28 12:56 華夢行 閱讀(1852) | 評論 (0)編輯 收藏
          INSTR方法的格式為
          INSTR(源字符串, 目標字符串, 起始位置, 匹配序號)

          ////匹配序號是從左邊開始數(shù)起,而不管其實位置的正負。
          ///當起始位置為負數(shù)時,從右邊數(shù)起來計算返回的結(jié)果
          select? instr(' ',' ',1,1)返回的值為空

          例如:INSTR('CORPORATE FLOOR','OR', 3, 2)中,源字符串為'CORPORATE FLOOR', 目標字符串為'OR',起始位置為3,取第2個匹配項的位置。

          默認查找順序為從左到右。當起始位置為負數(shù)的時候,從右邊開始查找。

          所以SELECT INSTR('CORPORATE FLOOR', 'OR', -1, 1) "Instring"?FROM DUAL的顯示結(jié)果是

          Instring
          ——————
          14
          posted @ 2007-08-28 12:24 華夢行 閱讀(338) | 評論 (0)編輯 收藏
          ?ApplicationContext ctx = new ClassPathXmlApplicationContext("knight.xml");
          posted @ 2007-08-28 09:58 華夢行 閱讀(1326) | 評論 (0)編輯 收藏

          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{HH:mm:ss} %c{1} - %m%n

          log4j.rootLogger=WARN, stdout

          log4j.category.com.springinaction=DEBUG
          log4j.category.org.springframework=WARN

          posted @ 2007-08-27 17:29 華夢行 閱讀(286) | 評論 (0)編輯 收藏

          package com.springinaction.chapter01.knight;

          import java.lang.reflect.Method;

          import org.apache.log4j.Logger;
          import org.springframework.aop.MethodBeforeAdvice;


          public class MinstrelAdvice implements MethodBeforeAdvice {
          ? public void before(Method method, Object[] args, Object target)
          ????? throws Throwable {

          ??? Knight knight = (Knight) target;
          ???
          ??? Logger song = Logger.getLogger(target.getClass());
          ???
          ??? song.debug("Brave " + knight.getName() + " did " + method.getName());
          ? }
          }

          package com.springinaction.chapter01.knight;

          import org.springframework.beans.factory.BeanFactory;
          import org.springframework.beans.factory.xml.XmlBeanFactory;
          import org.springframework.context.ApplicationContext;
          import org.springframework.core.io.FileSystemResource;
          public class KnightApp {
          ? private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
          ????? .getLogger(KnightApp.class);
          ?
          ? public static void main(String[] args) throws Exception {
          ??? LOGGER.debug("Running KnightApp");
          ??? ApplicationContext m;
          ??? BeanFactory factory =
          ??????? new XmlBeanFactory(new FileSystemResource("knight.xml"));

          ///有XmlBeanFactory來負責具體的實現(xiàn)???? knight.xml必須要保存在項目的總目錄下面
          Knight knight =
          ??????? (Knight) factory.getBean("knight");

          ??? knight.embarkOnQuest();
          ??? System.out.println("ok");
          ??? LOGGER.debug("KnightApp Finished");
          ? }
          }

          posted @ 2007-08-27 16:11 華夢行 閱讀(552) | 評論 (0)編輯 收藏

          ?Spring中ApplicationContext加載機制。
          ????? ??? 加載器目前有兩種選擇:ContextLoaderListener和ContextLoaderServlet。
          ???????? 這兩者在功能上完全等同,只是一個是基于Servlet2.3版本中新引入的Listener接口實現(xiàn),而另一個基于Servlet接口實現(xiàn)。開發(fā)中可根據(jù)目標Web容器的實際情況進行選擇。

          配置非常簡單,在web.xml中增加:
          <listener>
          ? <listener-class>
          ?????? org.springframework.web.context.ContextLoaderListener
          ? </listener-class>
          </listener>
          或:
          <servlet>
          ??? <servlet-name>context</servlet-name>
          ??? <servlet-class>
          ?????? org.springframework.web.context.ContextLoaderServlet
          ??? </servlet-class>
          ??? <load-on-startup>1</load-on-startup>
          </servlet>?
          ?
          ????????? 通過以上配置,Web容器會自動加載/WEB-INF/applicationContext.xml初始化
          ApplicationContext實例,如果需要指定配置文件位置,可通過context-param加以指定:
          <context-param>
          ??? <param-name>contextConfigLocation</param-name>
          ??? <param-value>/WEB-INF/myApplicationContext.xml</param-value>
          </context-param>

          ??????? 配置完成之后,即可通過
          ?WebApplicationContextUtils.getWebApplicationContext方法在Web應(yīng)用中獲取ApplicationContext引用。

          如:ApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext();
          ??? LoginAction action=(LoginAction)ctx.getBean("action");

          posted @ 2007-08-27 16:03 華夢行 閱讀(176) | 評論 (0)編輯 收藏

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
          ??? "

          ///////在spring里所有的bean都是具體的實現(xiàn),所謂的裝配bean就是裝配一個具體的實現(xiàn)
          <beans>
          ? <bean id="quest"
          ????? class="com.springinaction.chapter01.knight.HolyGrailQuest"/>
          /////轉(zhuǎn)配一個實現(xiàn)類,用來實現(xiàn)一個接口

          ? <bean id="knightTarget"
          ????? class="com.springinaction.chapter01.knight.KnightOfTheRoundTable">
          ??? <constructor-arg>
          ????? <value>Bedivere</value>
          ??? </constructor-arg>
          ??? <property name="quest">
          ////這里是裝備一個這個類的屬性
          ????? <ref bean="quest"/>
          ??? </property>
          ? </bean>
          ?
          ? <bean id="minstrel"
          ????? class="com.springinaction.chapter01.knight.MinstrelAdvice"/>
          ?????
          ? <bean id="knight"
          ????? class="org.springframework.aop.framework.ProxyFactoryBean">
          ??? <property name="proxyInterfaces">
          ????? <list>
          ??????? <value>com.springinaction.chapter01.knight.Knight</value>
          ????? </list>
          ??? </property>
          ??? <property name="interceptorNames">
          ????? <list>
          ??????? <value>minstrel</value>
          ????? </list>
          ??? </property>
          ??? <property name="target"><ref bean="knightTarget"/></property>
          ? </bean>
          ?
          </beans>
          在spring 里所有的類都要實現(xiàn)接口與具體實現(xiàn)的分離? iGoHome.java?? iGoHomeImp.java? 這兩個類來具體完成

          List cat =sess.createCriteria(Cat.class).add(Restrictions.like("name","F%").addOrder(Order.asc("name")).addOrder(Order.desc("age")).setMaxResult(20).list();

          posted @ 2007-08-24 18:10 華夢行 閱讀(424) | 評論 (0)編輯 收藏
          ? <id??????? name="id"??????? type="java.lang.Integer"??????? column="ID">
          ??????????? <generator class="native">????????
          ??????????????? <param name="sequence">S_10924_1_BSE_BENEFICIARY</param>
          ??????????? </generator>
          ??? </id>
          posted @ 2007-08-24 17:06 華夢行 閱讀(168) | 評論 (0)編輯 收藏
          JTS Java Transaction Service 是 J2EE 架構(gòu)的關(guān)鍵元素。它與 JTA?Java Transaction API 結(jié)合在一起,使我們能夠構(gòu)建對于各種系統(tǒng)和網(wǎng)絡(luò)故障都非常健壯的分布式應(yīng)用程序。事務(wù)是可靠應(yīng)用程序的基本構(gòu)建塊 —— 如果沒有事務(wù)的支持,編寫可靠的分布式應(yīng)用程序?qū)⑹欠浅@щy的。幸運的是,JTS 執(zhí)行的大部分工作對于程序員都是透明的;J2EE 容器使事務(wù)劃分和資源征用對程序員來說幾乎是不可見的。這個由三個部分組成的系列文章的第一期講述了一些基礎(chǔ)知識,包括什么是事務(wù),以及事務(wù)對于構(gòu)建可靠的分布式應(yīng)用程序來說至關(guān)重要的原因。

          如果您閱讀過任何有關(guān) J2EE 的介紹性文章或者書籍,那么就會發(fā)現(xiàn),只有一小部分資料是專門針對 Java Transaction Service(JTS)或 Java Transaction API(JTA)的。這并不是因為 JTS 是 J2EE 中不重要的部分或者可選部分 —— 恰恰相反。JTS 受到的關(guān)注之所以會比 EJB 技術(shù)少,是因為它為應(yīng)用程序提供的服務(wù)非常透明 —— 很多開發(fā)人員甚至沒有注意到在他們的應(yīng)用程序中事務(wù)在哪里開始和結(jié)束。在某種意義上,JTS 的默默無聞恰恰是它的成功:因為它非常有效地隱藏了事務(wù)管理的很多細節(jié),因此,我們沒有聽說過或者談?wù)撨^很多關(guān)于它的內(nèi)容。但是,您可能想了解它在幕后都為您執(zhí)行什么功能。

          毫不夸張地說,沒有事務(wù)就不能編寫可靠的分布式應(yīng)用程序。事務(wù)允許采用某種控制方式修改應(yīng)用程序的持久性狀態(tài),以便使應(yīng)用程序?qū)τ诟鞣N各樣的系統(tǒng)故障(包括系統(tǒng)崩潰、網(wǎng)絡(luò)故障、電源故障甚至自然災(zāi)害)更加健壯。事務(wù)是構(gòu)建容錯、高可靠性以及高可用性應(yīng)用程序所需的基本構(gòu)建塊之一。

          posted @ 2007-08-24 16:34 華夢行 閱讀(886) | 評論 (0)編輯 收藏
          ? <Resource
          ??????????? name="jdbc/PathPlat"
          ??????????? auth="Container"
          ??????????? type="javax.sql.DataSource"
          ??????????? password="f"
          ??????????? driverClassName="oracle.jdbc.driver.OracleDriver"
          ??????????? maxIdle="50"
          ??????????? maxWait="5000"
          ??????????? username="t"
          ??????????? url="jdbc:oracle:thin:@192.168.0.1:1521:www"
          ??????????? removeAbandoned="true"
          ??????????? removeAbandonedTimeout="60"
          ??????????? maxActive="100"/>

          Context.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <Context path="/PathCrm" reloadable="true">
          ? <ResourceLink global="jdbc/PathPlat" name="jdbc/PathPlat" type="javax.sql.DataSource"/>
          </Context>
          ?
          <property? name="connection.datasource">java:comp/env/jdbc/PathPlat</property>?

          private String dbName ="java:comp/env/jdbc/SavingsAccountDB";

          java:comp/env是組件的JNDI上下文的名字(實際上這個上下文也作為一種資源來處理了,資源查找的過程可以是這樣:jndictxt = ctxt.lookup(“java:comp/env”)然后用這個jndictxt來查找資源,ref = jndictxt.lookup("jdbc/SavingsAccountDB")。)jdbc/SavingsAccountDB是資源引用的JNDI名(The jdbc/SavingsAccountDB string is the JNDI name for the resource reference,這句話可能意味著資源引用實際上也跟資源一樣處理成一種JNDI綁定對象了,但是實際上應(yīng)該不是這樣,因為在部署描述符中它是引用名元素。因為譯者也不是高手,所以這里的具體實現(xiàn)細節(jié)有待讀者自己研究了:)所以JDBC的DataSource對象的JNDI名就存儲在java:comp/env/jdbc的上下文子對象中。(組件運行環(huán)境的上下文層次需要進一步了解)

          5. 在Type列中選擇javax.sql.DataSource。前面說過它是數(shù)據(jù)庫連接工廠

          posted @ 2007-08-24 15:35 華夢行 閱讀(103) | 評論 (0)編輯 收藏
          set 元素里不能有重復(fù)
          posted @ 2007-08-24 14:22 華夢行 閱讀(138) | 評論 (0)編輯 收藏
          ?? Connection conn = HibernateUtil.getSession().connection();
          posted @ 2007-08-24 11:43 華夢行 閱讀(65) | 評論 (0)編輯 收藏
          僅列出標題
          共15頁: First 上一頁 7 8 9 10 11 12 13 14 15 下一頁 
          主站蜘蛛池模板: 海口市| 铜陵市| 新干县| 榆中县| 陇南市| 麻江县| 尼木县| 从化市| 大港区| 金溪县| 玛纳斯县| 武义县| 岚皋县| 依兰县| 明水县| 樟树市| 邳州市| 兰考县| 林甸县| 临沂市| 浦东新区| 辛集市| 桐梓县| 盘锦市| 德清县| 桐庐县| 五寨县| 泾阳县| 临邑县| 玉龙| 高州市| 土默特右旗| 贵溪市| 化德县| 兴宁市| 南澳县| 吐鲁番市| 潮安县| 平南县| 屏山县| 基隆市|