虛掩的門

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            10 Posts :: 23 Stories :: 5 Comments :: 0 Trackbacks

          Spring Notes2
          1.Read Resource
          ----------------------------------------------------
          applicationContext.xml的內容
          ----------------------------------------------------
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "

          <beans>


          ?<bean id="SpringHibernateSession" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
          ??<property name="configLocation">
          ???<value>file:src/hibernate.cfg.xml</value>
          ??</property>
          ?</bean>
          ?<!-- bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"-->
          ?<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
          ?<!--不必重啟Server-->
          ?
          ??<property name="basename">
          ???<!-- classpath:ApplicationResouces_zh_CN.properties ,? class -->

          ???<value>src\\com\\hardy\\struts\\ApplicationResources</value>
          ???<!-- value>com.hardy.struts.ApplicationResources</value -- error -->
          ???<!-- value>classpath:com\\hardy\\struts\\ApplicationResources</value -- correct -->

          ??</property>
          ?</bean>
          </beans>


          ----------------------------------------------------
          Test Java
          ----------------------------------------------------
          ApplicationContext ctx = new FileSystemXmlApplicationContext(
          ????"src\\applicationContext.xml");
          //方法1
          //ApplicationContext ctx = new FileSystemXmlApplicationContext(
          //????"D:\\Study-source\\Myeclipse4\\LibraryWeb\\src\\applicationContext.xml");
          //方法2
          //??ApplicationContext ctx = new FileSystemXmlApplicationContext(
          //????"classpath:applicationContext.xml");

          ??Object[] arg = new Object[] { "hardy", "xiaowei" };

          ??String username = ctx.getMessage("username", arg, Locale.US);
          ??System.err.println("username is\n" + username);

          ??? Resource rs = ctx
          ???? .getResource("classpath:com\\hardy\\struts\\ApplicationResources.properties");
          //另一種方式 ??
          //??????? .getResource("src\\com\\hardy\\struts\\ApplicationResources.properties");
          ??? if (rs.exists()) {
          ???System.err.println("rs is? existing");

          ???try {
          ????File file = rs.getFile();
          ???} catch (IOException e) {
          ????// TODO Auto-generated catch block
          ????e.printStackTrace();
          ???}
          ??}
          ?--------------------------------------
          ?WebContext的內容
          ?<listener>
          ??<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          ?</listener>
          ?
          或者
          ?<servlet>
          ??<servlet-name>context</servlet-name>
          ??<servlet-class>org.springframwork.web.context.ContextLoaderServlet</servlet-class>
          ??<load-on-startup>1</load-on-startup>
          ?</servlet>
          ?
          ?<context-param>
          ??<param-name>contextConfigLocation</param-name>
          ??<param-value>applicationContext.xml</param-value>
          ?</context-param>
          ?
          ?
          ??WebApplicationContextUtils.getWebApplicationContext
          ??
          ??TTS網站
          ??側重產品研發Struts
          ??側重先進的設計理念webwork2
          ??側重模板Velocity,Freemarker,XSLT
          ??
          ??
          ??動態AOP??
          OpenSessionInView模式
          對于Client應用通過Hessian訪問服務器端Service組件,我的建議則是把對象關聯操作封裝到DAO接口上去,例如


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 武汉市| 新绛县| 涟水县| 呼图壁县| 甘肃省| 板桥市| 玉溪市| 荆门市| 宣武区| 榆社县| 绍兴市| 崇仁县| 义乌市| 根河市| 东丰县| 定襄县| 泾源县| 泗洪县| 蛟河市| 北川| 收藏| 永宁县| 柏乡县| 彰化市| 岑巩县| 海盐县| 昌黎县| 湛江市| 景谷| 松阳县| 勐海县| 二连浩特市| 靖江市| 鹿邑县| 南郑县| 南和县| 苏尼特右旗| 秭归县| 长沙市| 宾川县| 竹北市|