ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美精品九九久久,欧美一区综合,蜜臀精品久久久久久蜜臀http://www.aygfsteel.com/ziwolf/archive/2006/12/26/90089.htmlziwolfziwolfTue, 26 Dec 2006 05:35:00 GMThttp://www.aygfsteel.com/ziwolf/archive/2006/12/26/90089.htmlhttp://www.aygfsteel.com/ziwolf/comments/90089.htmlhttp://www.aygfsteel.com/ziwolf/archive/2006/12/26/90089.html#Feedback0http://www.aygfsteel.com/ziwolf/comments/commentRss/90089.htmlhttp://www.aygfsteel.com/ziwolf/services/trackbacks/90089.html如果你ä‹É用的是Servlet2.4 及以上的web容器åQŒé‚£ä¹ˆä»…需要在web.xml 中增加ContextListener卛_¯

<web-app>
...
<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
...
</web-app>


如果你ä‹É用的是早期版本web容器 Servlet 2.4 以前åQŒé‚£ä¹ˆéœ€è¦ä‹É用一个javax.servlet.Filter 的实çŽ?br />
<web-app>
..
<filter>
    <filter-name>requestContextFilter</filter-name>
    <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>requestContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
...
</web-app>

----------------------------------------------------------------------
RequestContextListener and RequestContextFilter 两个¾cÕdšçš„都是同æ ïLš„工作åQ›å°†HTTP request 对象¾l‘定åˆîCؓ该请求提供服务的Thread。这使具有request or session 作用域的bean能够在后面的调用链中被访问到ã€?br />

作用域bean 与依èµ?br />如果打算ž®†ä¸€ä¸ªHttp request 范围的bean 注入到别一个bean 中,那么需要注入一个AOP代理来替代被注入的作用域beanåQŒä¹Ÿž®±æ˜¯è¯´éœ€è¦æ³¨å…¥ä¸€ä¸ªä»£ç†å¯¹è±¡ã€?br />注意
<aop:scoped-proxy/>不能和作用域为singleton æˆ?prototype çš„bean一起ä‹É用ã€?br />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- a HTTP Session-scoped bean exposed as a proxy -->
<bean id="userPreferences" class="com.foo.UserPreferences" scope="session">
<!-- this next element effects the proxying of the surrounding bean -->
<aop:scoped-proxy/>
</bean>
<!-- a singleton-scoped bean injected with a proxy to the above bean -->
<bean id="userService" class="com.foo.SimpleUserService">
<!-- a reference to the proxied 'userPreferences' bean -->
<property name="userPreferences" ref="userPreferences"/>
</bean>




初始化回�br />
可以在Bean 定义中指定一个普通的初始化方法,卛_œ¨XML配置文äšg中通过指定init-method 属性来完成ã€?br />
<bean id="exampleInitBean" class="examples.ExampleBean" init-method="init" />

public class ExampleBean {
    public void init(){
        //do some initialization work
    }
}


析构回调
<bean id="exampleInitBean" class="examples.ExampleBean" destory-method="cleanup"/>

public class ExampleBean {
    public void cleanup(){
        //do some destruction work..
    }
}




ziwolf 2006-12-26 13:35 发表评论
]]>
生成MD5åQŒBASE64http://www.aygfsteel.com/ziwolf/archive/2006/12/22/89483.htmlziwolfziwolfFri, 22 Dec 2006 03:50:00 GMThttp://www.aygfsteel.com/ziwolf/archive/2006/12/22/89483.html  byte[] returnByte = null;
  try{
      MessageDigest md5 = MessageDigest.getInstance("MD5");
      returnByte = md5.digest(strSrc.getBytes("UTF8"));
   }catch(Exception e){
      e.printStackTrace();
  }
  return returnByte;
 }
 
 public String getBase64Encode(byte[] src){
    String requestValue="";
    try{
   BASE64Encoder base64en =  new BASE64Encoder();
   requestValue = base64en.encode(src);
  }catch(Exception e){
   e.printStackTrace();
  }
    return requestValue;
 }


ziwolf 2006-12-22 11:50 发表评论
]]>
Ö÷Õ¾Ö©Öë³ØÄ£°å£º °¢Â³¿Æ¶ûÇ߯ì| ¸£¹±ÏØ| ÌìÕòÏØ| »ôÇñÏØ| ²ÔÏªÏØ| º£³ÇÊÐ| ÁÙÒØÏØ| º£ÄÏÊ¡| ÆÁ¶«ÏØ| ºá·åÏØ| ÏæÏçÊÐ| ËÄ»áÊÐ| ³¤ÄþÏØ| ¹±¸ÂÏØ| °åÇÅÊÐ| Èʲ¼ÏØ| ÁúÀïÏØ| ÂåÂ¡ÏØ| ³¤ÄþÏØ| ÂÞÔ´ÏØ| ÐÞË®ÏØ| ÆëºÓÏØ| Óý¶ù| ÌØ¿ËË¹ÏØ| äÒÖÐÏØ| Óå±±Çø| ÎijÉÏØ| ¹®ÁôÏØ| Öн­ÏØ| ºø¹ØÏØ| ÂÞÆ½ÏØ| ÇåºÓÏØ| ³»ÖÝÊÐ| ÁººÓÏØ| ·ÚÑôÊÐ| ÄϲýÏØ| ÐÂÃÜÊÐ| ºÍË¶ÏØ| ÕżҴ¨| ËþºÓÏØ| а²ÏØ|