隨筆-77  評論-5  文章-2  trackbacks-0
           

          package com.zte.platform;

          import java.io.IOException;

          import javax.faces.webapp.FacesServlet;
          import javax.servlet.ServletConfig;
          import javax.servlet.ServletException;
          import javax.servlet.ServletRequest;
          import javax.servlet.ServletResponse;
          import javax.servlet.http.HttpServlet;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;

          public class ZteFacesServlet extends HttpServlet
          {

           private static final String INIT_PARAM_ERROR_PAGE = "errorPage";
                  private Log log = LogFactory.getLog(getClass());       
                 

           private FacesServlet delegate;

           private String errorPage;

           public void init(ServletConfig servletConfig) throws ServletException
           {
            delegate = new FacesServlet();
            delegate.init(servletConfig);
            errorPage = servletConfig.getInitParameter(INIT_PARAM_ERROR_PAGE);
           }

           public void destroy()
           {
            delegate.destroy();
           }

           public ServletConfig getServletConfig()
           {
            return delegate.getServletConfig();
           }

           public String getServletInfo()
           {
            return delegate.getServletInfo();
           }

           public void service(ServletRequest request, ServletResponse response)
             throws ServletException, IOException
           {
            try
            {
             delegate.service(request, response);
            } catch (Throwable e)
            {
                      log.error("page exception ,redirect to error page ",e);
                      try{
             redirectToErrorPage((HttpServletRequest) request,
               (HttpServletResponse) response);
                      }
                      catch(Exception ex)
                      {
                       log.error("fail to redirect to error page",ex);
                       //throw new RuntimeException("fail to redirect to error page,original exceptioin is", e);
                      }
            }
           }

           private void redirectToErrorPage(HttpServletRequest request,
             HttpServletResponse response) throws IOException
           {
            if (!"".equals(errorPage))
            {
             response.sendRedirect(request.getContextPath() + errorPage);
            }
           }

          }


          文章來源:http://stocknewbie.bokee.com/viewdiary.18876476.html
          posted @ 2009-05-01 10:52 huohuo 閱讀(183) | 評論 (0)編輯 收藏

          divHtml = divHtml + "<iframe src='about:blank' style='position:absolute;top:0px;left:0px; visibility:inherit;  width:190px;height:232px;z-index:-1; scrolling='no' frameborder='0' filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';'></iframe>"
            

          document.all.myDiv.innerHTML = divHtml;

           

          這種方式有個(gè)問題,就是width和height寫死了,

          如果div自身設(shè)置了width和height,可以將iframe的width,height設(shè)置成100%

          divHtml = divHtml + "<iframe src='about:blank' style='position:absolute;top:0px;left:0px; visibility:inherit;  width:100%;height:100%;z-index:-1; scrolling='no' frameborder='0' filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';'></iframe>"


          文章來源:http://stocknewbie.bokee.com/viewdiary.18876477.html
          posted @ 2009-05-01 10:52 huohuo 閱讀(238) | 評論 (0)編輯 收藏

          import java.io.BufferedReader;
          import java.io.File;
          import java.io.FileInputStream;
          import java.io.FileOutputStream;
          import java.io.FileReader;
          import java.io.IOException;
          import java.io.InputStream;
          import java.io.PushbackInputStream;
          import java.util.ArrayList;
          import java.util.HashSet;
          import java.util.List;
          import java.util.Set;

          public class UtfTool
          {

              /**
               * ant 編譯之后的result文件,注意要編譯提示錯(cuò)誤的文件名要在同一行
               * 可以設(shè)置命令提示窗口的緩沖區(qū)大小實(shí)現(xiàn)
               * @param resultFileName
               */
              public static Set getFileNamesFromCompileResult(String resultFileName)
               throws java.io.IOException
              {
           Set<String> set = new HashSet();
           BufferedReader reader = new BufferedReader(new FileReader(
            resultFileName));
           String start = "[javac] ";
           int startLen = start.length();
           String end = ".java:";
           int endLen = end.length();
           
           String errMsg = "\\65279";
           while (reader.ready())
           {
               String line = reader.readLine();
               int indexStart = line.indexOf(start);
              
               if(line.indexOf(errMsg) == -1)
               {
            continue;
               }
               if (indexStart != -1)
               {
            int indexEnd = line.indexOf(end);
            if (indexEnd != -1)
            {
                String name = line.substring(indexStart + startLen,
                 indexEnd + endLen - 1);
                set.add(name.trim());
            }
               }
           }
           return set;

              }
             
              /**
               * 讀取流中前面的字符,看是否有bom,如果有bom,將bom頭先讀掉丟棄
               * @param in
               * @return
               * @throws IOException
               */
              public static InputStream getInputStream(InputStream in) throws IOException
              {

           PushbackInputStream testin = new PushbackInputStream(in);
           int ch = testin.read();
           if (ch != 0xEF)
           {
               testin.unread(ch);
           } else if ((ch = testin.read()) != 0xBB)
           {
               testin.unread(ch);
               testin.unread(0xef);
           } else if ((ch = testin.read()) != 0xBF)
           {
               throw new IOException("錯(cuò)誤的UTF-8格式文件");
           } else
           {
               //不需要做,這里是bom頭被讀完了
              //// System.out.println("still exist bom");

           }
           return testin;

              }
             
             
             
              /**
               * 根據(jù)一個(gè)文件名,讀取完文件,干掉bom頭。
               * @param fileName
               * @throws IOException
               */
              public static void trimBom(String fileName) throws IOException
              {

           FileInputStream fin = new FileInputStream(fileName);
           //開始寫臨時(shí)文件
           InputStream in = getInputStream(fin);
           String tmpFileName = fileName + ".tmp";
           FileOutputStream out = new FileOutputStream(tmpFileName);
           byte b[] = new byte[4096];

           int len = 0;
           while (in.available() > 0)
           {
               len = in.read(b, 0, 4096);
               out.write(b, 0, len);
           }

           in.close();
           fin.close();
           out.close();

           //臨時(shí)文件寫完,開始將臨時(shí)文件寫回本文件。
           in = new FileInputStream(tmpFileName);
           System.out.println("[" + fileName + "]");
           out = new FileOutputStream(fileName);

           while (in.available() > 0)
           {
               len = in.read(b, 0, 4096);
               out.write(b, 0, len);
           }
           in.close();
           out.close();
              }

              /**
               * 根據(jù)ant編譯錯(cuò)誤來去除bom
               * @param resultFile
               * @throws IOException
               */
              static void trimBomByCompileResult(String resultFile) throws IOException
              {
           Set<String> set = getFileNamesFromCompileResult(resultFile);
           for (String fName : set)
           {
               trimBom(fName);
           }
              }

              public static void main(String[] args) throws IOException
              {
           trimBomByCompileResult("c:/result3.txt");
           
           ///List<String> list = getFileNamesFromCompileResult(resultFile);

          // InputStream in = new FileInputStream(
          //  "D:/cc/SSB_SRC_DEV_lijinglin2/TP_SSB/SSB_CJ203_Component/ProductCode/com/zte/ssb/component/access/implementation/dao/ImplementationDAO.java");
          // getInputStream2(in);
          // in.close();
              }
          }


          文章來源:http://stocknewbie.bokee.com/viewdiary.22061282.html
          posted @ 2009-05-01 10:52 huohuo 閱讀(1864) | 評論 (0)編輯 收藏

          執(zhí)行sql

          select  o.name,cl.name,cm.text from sysobjects o,syscolumns cl, syscomments cm
           where o.id = cl.id and cl.cdefault = cm.id  and o.type='U'
            and o.name='test2' and cl.name like 'col%'

           

          test2是標(biāo)明, col%是列名通配符, 'U' 表示表格是用戶表

           

          返回結(jié)果:

           

          name                           name                           text                                                                                                                                                                                                                                                           
          ----                           ----                           ----                                                                                                                                                                                                                                                           
          test2                          col1                           DEFAULT (0)                                                                                                                                                                                                                                                    
          test2                          col2                           DEFAULT  2                                                                                                                                                                                                                                                     
          test2                          col3                           DEFAULT  getdate()            

           

           

          syscolumns 中 id 表示對應(yīng)的表格在sysobjects中id, cdefault表示在syscomments中的缺省值注釋id

           

           

          缺省值可能會(huì)出現(xiàn)函數(shù), 例如  default getdate(),

          所以我覺得應(yīng)該這個(gè)缺省值可以剝離掉default, 如果使用hibernate實(shí)現(xiàn),還只能用dynamic insert,dynamic update.

           

           


          文章來源:http://stocknewbie.bokee.com/viewdiary.31463433.html
          posted @ 2009-05-01 10:52 huohuo 閱讀(491) | 評論 (0)編輯 收藏
          僅列出標(biāo)題
          共5頁: 上一頁 1 2 3 4 5 
          主站蜘蛛池模板: 望江县| 前郭尔| 嵊泗县| 青龙| 昌图县| 铜山县| 钟山县| 怀远县| 丹寨县| 同心县| 靖江市| 莱州市| 宣汉县| 陇川县| 昌都县| 察雅县| 慈利县| 谢通门县| 交口县| 吐鲁番市| 贡山| 水城县| 赤壁市| 兴国县| 买车| 那曲县| 尉氏县| 马边| 宝鸡市| 凤阳县| 克拉玛依市| 大兴区| 麟游县| 五原县| 禹城市| 江达县| 喀什市| 全椒县| 绍兴市| 桃江县| 黄龙县|