随笔-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 阅读(179) | 评论 (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;

 

这种方式有个问题,就是width和height写死了,

如果div自身设置了width和height,可以将iframe的width,height设置成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 阅读(235) | 评论 (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文件,注意要编译提示错误的文件名要在同一行
     * 可以设置命令提示窗口的缓冲区大小实现
     * @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("错误的UTF-8格式文件");
 } else
 {
     //不需要做,这里是bom头被读完了
    //// System.out.println("still exist bom");

 }
 return testin;

    }
   
   
   
    /**
     * 根据一个文件名,读取完文件,干掉bom头。
     * @param fileName
     * @throws IOException
     */
    public static void trimBom(String fileName) throws IOException
    {

 FileInputStream fin = new FileInputStream(fileName);
 //开始写临时文件
 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();

 //临时文件写完,开始将临时文件写回本文件。
 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();
    }

    /**
     * 根据ant编译错误来去除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 阅读(1852) | 评论 (0)编辑 收藏

执行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是标明, col%是列名通配符, 'U' 表示表格是用户表

 

返回结果:

 

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

 

 

syscolumns 中 id 表示对应的表格在sysobjects中id, cdefault表示在syscomments中的缺省值注释id

 

 

缺省值可能会出现函数, 例如  default getdate(),

所以我觉得应该这个缺省值可以剥离掉default, 如果使用hibernate实现,还只能用dynamic insert,dynamic update.

 

 


文章来源:http://stocknewbie.bokee.com/viewdiary.31463433.html
posted @ 2009-05-01 10:52 huohuo 阅读(485) | 评论 (0)编辑 收藏
仅列出标题
共5页: 上一页 1 2 3 4 5