<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    dingfirst

    On the Road

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      8 隨筆 :: 2 文章 :: 3 評論 :: 0 Trackbacks

    2006年7月26日 #

    勵(lì)精圖治
    posted @ 2007-09-11 16:29 dingfirst 閱讀(178) | 評論 (0)編輯 收藏

    現(xiàn)在在干啥啊!
    沒有方向,沒有動(dòng)力。
    十年之后會(huì)是什么樣子呢?
    nnd
    郁悶!
    極其郁悶!!!

    改變,
    要改變啊!!

    posted @ 2007-04-25 17:13 dingfirst 閱讀(220) | 評論 (0)編輯 收藏

    問題:
    ??????直接用URLEncoder.encode(fileName,"UTF-8"),得到的文件名長度會(huì)被截?cái)唷?br />
    解決方法是:
    ??????文件名先用“GB2312”編碼,然后用“ISO8859_1”解碼。當(dāng)然也可以在將文件名保存到數(shù)據(jù)庫之前用“GB2312”編碼。

    代碼如下:

    ?1conn?=?DBUtil.getConnection();
    ?2????????????ps?=?conn.prepareStatement("SELECT?FILE_NAME,?CONTENT_TYPE,?CONTENT?FROM?PUB_JOB_ATTACHMENTS?WHERE?ATTACHID?=??");
    ?3????????????ps.setString(1,getAttachId());
    ?4????????????rs?=?ps.executeQuery();
    ?5????????????if(rs.next())
    ?6????????????{
    ?7????????????????//java.net.URLEncoder.encode(rs.getString("FILE_NAME"),?"UTF-8")
    ?8????????????????response.setContentType(rs.getString("CONTENT_TYPE"));
    ?9????????????????String?fileName=rs.getString("FILE_NAME");
    10????????????????fileName=URLEncoder.encode(fileName,"GB2312");
    11????????????????fileName=URLDecoder.decode(fileName,?"ISO8859_1");
    12????????????????response.addHeader("Content-Disposition",?"attachment;?filename=\""?+?fileName?+?"\"");
    13????????????????Blob?content?=?rs.getBlob("CONTENT");
    14????????????????InputStream?ins?=?content.getBinaryStream();
    15????????????????byte?buffer[]?=?new?byte[1024];
    16????????????????int?length?=?-1;
    17????????????????outs?=?response.getOutputStream();
    18????????????????while((length?=?ins.read(buffer))?!=?-1)
    19????????????????????outs.write(buffer,?0,?length);
    20????????????????ins.close();
    21????????????????outs.flush();
    22????????????}

    posted @ 2006-11-27 18:59 dingfirst 閱讀(1175) | 評論 (0)編輯 收藏

    先看一下Proxy的兩種用法:

    public ? interface ?Foo? {
    ????
    int ?doSomthing();
    }
    ???一個(gè)基本的實(shí)現(xiàn):
    public?class?FooImpl?implements?Foo?{
    ????
    public?FooImpl()?{
    ????}


    ????
    public?int?doSomthing()?{
    ????????System.out.println(
    "FooImpl?doSomthing");
    ????????
    return?10;
    ????}

    ????
    }
    ???調(diào)用處理類,這也是aop的一種實(shí)現(xiàn)方式,呵呵。
    public?class?MyInvocationHandler?implements?InvocationHandler{
    ????Object?proxyObject;
    ????
    ????
    public?MyInvocationHandler(Object?_proxyObject)?{
    ????????
    this.proxyObject=_proxyObject;
    ????}


    ????
    public?Object?invoke(Object?proxy,?Method?method,?Object[]?args)?throws?Throwable?{
    ????????System.out.println(
    "in?proxy?instance");
    ????????
    return?method.invoke(proxyObject,args);
    ????}

    }
    ???兩種實(shí)現(xiàn)方式:
    public?class?ProxyUse?{
    ????
    public?ProxyUse()?{
    ????}


    ????
    public?void?useProxy1()?throws?SecurityException,?NoSuchMethodException,?InvocationTargetException,
    ????????????IllegalArgumentException,?IllegalAccessException,?InstantiationException?
    {
    ????????FooImpl?obj?
    =?new?FooImpl();
    ????????InvocationHandler?handler?
    =?new?MyInvocationHandler(obj);
    ????????Class?proxyClass?
    =?Proxy.getProxyClass(
    ????????????????Foo.
    class.getClassLoader(),?new?Class[]?{Foo.class});
    ????????Foo?f?
    =?(Foo)?proxyClass.
    ????????????????getConstructor(
    new?Class[]?{InvocationHandler.class}).
    ????????????????newInstance(
    new?Object[]?{handler});
    ????????System.out.println(f.doSomthing());
    ????}

    ????
    ????
    public?void?useProxy2()?throws?SecurityException,?NoSuchMethodException,?InvocationTargetException,
    ????????????IllegalArgumentException,?IllegalAccessException,?InstantiationException?
    {
    ????????FooImpl?obj?
    =?new?FooImpl();
    ????????InvocationHandler?handler?
    =?new?MyInvocationHandler(obj);
    ????????Foo?f?
    =?(Foo)?Proxy.newProxyInstance(
    ????????????Foo.
    class.getClassLoader(),
    ????????????
    new?Class[]?{?Foo.class?},
    ????????????handler
    ????????????);
    ????????System.out.println(f.doSomthing());
    ????}

    ????
    ????
    public?static?void?main(String?[]?args){
    ????????ProxyUse?use
    =new?ProxyUse();
    ????????
    try{
    ????????????use.useProxy1();
    ????????????use.useProxy2();
    ????????}
    catch(Exception?ex){
    ????????????ex.printStackTrace();
    ????????}

    ????}


    }

    看一下java api doc

    static?InvocationHandlergetInvocationHandler(Object?proxy)
    ??????????返回指定代理實(shí)例的調(diào)用處理程序。
    static?Class<?>getProxyClass(ClassLoader?loader, Class<?>...?interfaces)
    ??????????返回代理類的 java.lang.Class 對象,并向其提供類加載器和接口數(shù)組。
    static?booleanisProxyClass(Class<?>?cl)
    ??????????當(dāng)且僅當(dāng)指定的類通過 getProxyClass 方法或 newProxyInstance 方法動(dòng)態(tài)生成為代理類時(shí),返回 true。
    static?ObjectnewProxyInstance(ClassLoader?loader, Class<?>[]?interfaces, InvocationHandler?h)
    ??????????返回一個(gè)指定接口的代理類實(shí)例,該接口可以將方法調(diào)用指派到指定的調(diào)用處理程序。

    沒時(shí)間了,先這樣吧。


    ?

    posted @ 2006-07-26 17:48 dingfirst 閱讀(266) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲一区二区三区在线网站| 国产黄色片免费看| 国产精品亚洲不卡一区二区三区| 丝瓜app免费下载网址进入ios| 亚洲熟妇av一区二区三区下载 | 四虎亚洲国产成人久久精品| 中文在线观看国语高清免费| 91亚洲国产成人久久精品网址 | 亚洲精品国产成人片| 成人免费AA片在线观看| 一个人看的在线免费视频| 亚洲午夜一区二区电影院| 亚洲精品无码永久在线观看| 很黄很黄的网站免费的| 精品熟女少妇aⅴ免费久久| 亚洲人成综合网站7777香蕉| 亚洲成A人片在线观看WWW| 国产高清免费的视频| 久久A级毛片免费观看| 特级毛片在线大全免费播放| tom影院亚洲国产一区二区| 亚洲中文字幕在线第六区| 毛片a级三毛片免费播放| 免费看男人j放进女人j免费看| 国产成人综合久久精品亚洲| 亚洲综合激情视频| 亚洲伊人久久精品影院| 日韩一区二区三区免费体验| 最近2019免费中文字幕6| 成在人线av无码免费高潮水| 爱情岛论坛亚洲品质自拍视频网站| 亚洲伊人久久大香线蕉影院| 亚洲人成网站影音先锋播放| 永久亚洲成a人片777777| 国产婷婷高清在线观看免费| 无码av免费毛片一区二区| 久草免费福利资源站| 久久精品无码专区免费| 免费精品国自产拍在线播放| 亚洲AⅤ男人的天堂在线观看| 亚洲一卡2卡3卡4卡国产网站 |