虚掩的门

  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" "http://www.springframework.org/dtd/spring-beans.dtd">

<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接口上去,例如

posted on 2006-09-18 10:12 Hardy虚掩的门 阅读(187) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: