??xml version="1.0" encoding="utf-8" standalone="yes"?>国产黄色精品,综合欧美国产视频二区,日韩亚洲国产中文字幕http://www.aygfsteel.com/jackson110/archive/2007/08/16/137142.htmljacksontotojacksontotoThu, 16 Aug 2007 02:57:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/08/16/137142.htmlhttp://www.aygfsteel.com/jackson110/comments/137142.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/08/16/137142.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/137142.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/137142.htmlq_QLucene 2.1.0QJRE 1.4QOracle 10gQIBM Web Sphere?br>      数据表:(x)Article。字D:(x)IDQ自动增长)(j)QTitleQStringQ,ContentQStringQ。共?50000条记录?br>      对Article建立索引Q?

 1import org.apache.lucene.analysis.*;
 2import org.apache.lucene.analysis.cn.*;
 3import org.apache.lucene.document.*;
 4import org.apache.lucene.index.*;
 5import java.sql.*;
 6import oracle.jdbc.pool.*;
 7
 8public class Index {
 9 private String url="jdbc:oracle:thin:@//192.168.0.l:1521/Test";
10 private String user="terry";
11 private String password="dev";
12 private Connection con=null;
13 private Statement st=null;
14 private ResultSet rs=null;
15 private String indexUrl="E:\\ArticleIndex";
16
17 private ResultSet getResult() throws Exception{
18        OracleDataSource ods=new OracleDataSource();
19
20        ods.setURL(this.url);
21        ods.setUser(this.user);
22        ods.setPassword(this.password);
23
24 this.con=ods.getConnection();
25 this.st=this.con.createStatement();
26 this.rs=this.st.executeQuery("SELECT * FROM Article");
27
28 return this.rs;
29    }
30
31 public void createIndex() throws Exception{
32        ResultSet rs=this.getResult();
33
34        Analyzer chineseAnalyzer=new ChineseAnalyzer();
35        IndexWriter indexWriter=new IndexWriter(this.indexUrl,chineseAnalyzer,true);
36        indexWriter.setMergeFactor(100);
37        indexWriter.setMaxBufferedDocs(100);
38
39        java.util.Date startDate=new java.util.Date();
40
41        System.out.println("开始烦(ch)引时_(d)(x)"+startDate);
42
43        executeIndex(rs,indexWriter);
44
45        indexWriter.optimize();
46
47        indexWriter.close();
48
49        java.util.Date endDate=new java.util.Date();
50
51        System.out.println("索引l束旉Q?+endDate);
52        System.out.println("p费:(x)"+(endDate.getTime()-startDate.getTime())+"ms");
53    }
54
55 private void executeIndex(ResultSet rs,IndexWriter indexWriter) throws Exception{
56 int i=0;
57
58 while(rs.next()){
59 int id=rs.getInt("ID");
60            String title=rs.getString("TITLE");
61            String info=rs.getString("CONTENT");
62
63            Document doc=new Document();
64
65            Field idField=new Field("ID",Integer.toString(id),Field.Store.YES,Field.Index.NO,Field.TermVector.NO);
66            Field titleField=new Field("Title",title,Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.YES);
67         Field infoField=new Field("Content",title,Field.Store.YES,Field.Index.TOKENIZED,Field.TermVector.YES);
68
69            doc.add(idField);
70            doc.add(titleField);
71            doc.add(infoField);
72
73            indexWriter.addDocument(doc);
74
75            i++;
76        }
77
78 this.close();
79
80        System.out.println("共处理记录:(x)"+i);
81    }
82
83 private void close() throws Exception{
84 this.rs.close();
85 this.st.close();
86 this.con.close();
87    }
88}

      查找Q?

 1import java.io.*;
 2import org.apache.lucene.analysis.cn.*;
 3import org.apache.lucene.search.*;
 4import org.apache.lucene.store.*;
 5import org.apache.lucene.document.*;
 6import org.apache.lucene.queryParser.QueryParser;
 7
 8import java.util.*;
 9
10public class Search {
11
12 private static final String indexUrl="E:\\ArticleIndex";
13
14 public static void main(String[] args) throws Exception {
15/**/    /*建立索引代码Q查找时注释*/
16 //Index index=new Index();
17
18 //index.createIndex();
19
20
21
22
23        File indexDir=new File(indexUrl);
24        FSDirectory fdir=FSDirectory.getDirectory(indexDir);
25
26        IndexSearcher searcher=new IndexSearcher(fdir);
27
28//对中文徏立解析(必须Q?br>29        QueryParser parser=new QueryParser("Title",new ChineseAnalyzer());
30        Query query=parser.parse("李湘");
31
32        Date startDate=new Date();
33        System.out.println("(g)索开始时_(d)(x)"+startDate);
34
35        Hits result=searcher.search(query);
36
37 for(int i=0;i<result.length();i++){
38            Document doc=result.doc(i);
39
40            System.out.println("内容Q?+doc.get("Content"));
41        }
42
43        Date endDate=new Date();
44
45        System.out.println("共有记录Q?+result.length());
46        System.out.println("p费:(x)"+(endDate.getTime()-startDate.getTime()));
47    }
48
49}

      l测试,建立索引文g大概׃(jin)11分钟。一般情况下Q和用SQL执行LIKE查询差不多?

      当然Q这只是我的_略试。最q一阶段Q我?x)对Luceneq行代码深入研究?

jacksontoto 2007-08-16 10:57 发表评论
]]>
构徏各种Lucene Queryhttp://www.aygfsteel.com/jackson110/archive/2007/08/16/137141.htmljacksontotojacksontotoThu, 16 Aug 2007 02:56:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/08/16/137141.htmlhttp://www.aygfsteel.com/jackson110/comments/137141.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/08/16/137141.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/137141.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/137141.html阅读全文

jacksontoto 2007-08-16 10:56 发表评论
]]>
Java_֓文章攉http://www.aygfsteel.com/jackson110/archive/2007/08/15/136813.htmljacksontotojacksontotoWed, 15 Aug 2007 00:50:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/08/15/136813.htmlhttp://www.aygfsteel.com/jackson110/comments/136813.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/08/15/136813.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/136813.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/136813.html 

JDBC TM入门指南
http://www.zebcn.com/html/200411\103.html
Java E序~码规范
http://www.zebcn.com/html/200411\104.html
JavaBean入门
http://www.zebcn.com/html/200411\105.html
对JAVA语言的十个常见误?
http://www.zebcn.com/html/200411\114.html
析JAVA的XML~程
http://www.zebcn.com/html/200411\115.html
Java技巧:(x)列表排序
http://www.zebcn.com/html/200411\129.html
Java异常处理
http://www.zebcn.com/html/200411\130.html
Java中初学者比较爱出错的运问?
http://www.zebcn.com/html/200411\131.html
cL释文编写方?
http://www.zebcn.com/html/200411\132.html
对JAVA语言的十个常见误?
http://www.zebcn.com/html/200411\133.html
析JAVA的XML~程(to:初学者们)
http://www.zebcn.com/html/200411\134.html
关于H口的操作详?
http://www.zebcn.com/html/200411\135.html
Java 语言中的 return 语句
http://www.zebcn.com/html/200411\136.html
Javaq接各种数据库的实例
http://www.zebcn.com/html/200411\137.html
在Java中实现回调过E?
http://www.zebcn.com/html/200411\138.html
Java 中对文g的读写操作之比较
http://www.zebcn.com/html/200412\166.html
[原创](mi)Java的文件读和写
http://www.zebcn.com/html/200412\167.html
java-在Java中读写Excel文g
http://www.zebcn.com/html/200412\171.html
实战JMS (?
http://www.zebcn.com/html/200412\172.html
取得旉的函?
http://www.zebcn.com/html/200412\177.html
JAVA-如何实现TIMER功能
http://www.zebcn.com/html/200412\179.html
数据库访问简单实?
http://www.zebcn.com/html/200412\180.html
数据库操作装到Javabean
http://www.zebcn.com/html/200412\187.html
用Java~写扫雷游戏Q-代码思想
http://www.zebcn.com/html/200412\190.html
Hibernate事务处理机制
http://www.zebcn.com/html/200412\191.html
jboss 4.0 中JSP调用EJB的简单例?
http://www.zebcn.com/html/200412\192.html
JSP WEBServer的实现原?
http://www.zebcn.com/html/200412\193.html
Spring 入门(一个简单的例子)
http://www.zebcn.com/html/200501\204.html

使用Java生成Pdf文档
http://www.zebcn.com/html/200501\205.html
JAVA生成JPG~略?
http://www.zebcn.com/html/200501\206.html
学习(fn)J2ME~程需要掌握的七种技?
http://www.zebcn.com/html/200501\210.html
W一个EJB3.0范例
http://www.zebcn.com/html/200502\213.html
Java RMI 单示?
http://www.zebcn.com/html/200502\215.html
[原创](mi)java初学者之l验ȝ
http://www.zebcn.com/html/200502\217.html
Tomcat配置技巧Top 10
http://www.zebcn.com/html/200502\218.html
学习(fn)Java?0个基本概?
http://www.zebcn.com/html/200502\222.html
java常用的加?解密,数字{֐{API
http://www.zebcn.com/html/200502\227.html
一U简单的strutsU连菜单实现Ҏ(gu)
http://www.zebcn.com/html/200502\228.html
2005q??日Java新品发布公告
http://www.zebcn.com/html/200504\232.html
Javaq接各种数据库的实例
http://www.zebcn.com/html/200504\241.html
Java常见问题集锦Q来自Sun中国官方站)(j)
http://www.zebcn.com/html/200504\243.html
java 文g操作大全
http://www.zebcn.com/html/200504\249.html
J2EE目危机【翻译?
http://www.zebcn.com/html/200505\254.html
JAVAҎ(gu)字证书的常用操作
http://www.zebcn.com/html/200510\275.html
三种整合Struts 应用E序与Spring的方?
http://www.zebcn.com/html/200511\278.html
[分n]Ant?
http://www.zebcn.com/html/200511\282.html
Struts 的动态复选框
http://www.zebcn.com/html/200511\289.html
集成 Struts、Tiles ?nbsp;JavaServer Faces
http://www.zebcn.com/html/200511\293.html
J2ME应用E序内存?sh)化三?
http://www.zebcn.com/html/200512\338.html
一个生成无重复数字的代?
http://www.zebcn.com/html/200512\351.html
RSS 开发教E?
http://www.zebcn.com/html/200512\355.html
java写的贪吃蛇游?
http://www.zebcn.com/html/200512\360.html
应用Java技术开发WAP应用E序
http://www.zebcn.com/html/200512\361.html
web框架Jakarta Tapestry 4.0-rc-3 发布
http://www.zebcn.com/html/200512\366.html
校验获取w䆾证信息的JAVAE序
http://www.zebcn.com/html/200512\368.html
模式实践Q观察者模式与Spring
http://www.zebcn.com/html/200512\369.html
XMLd/存取属性的Java工具cd
http://www.zebcn.com/html/200512\370.html
JAVA写的四则混合q算
http://www.zebcn.com/html/200512\371.html
Web框架RIFE/Laszlo 1.3.1 发布
http://www.zebcn.com/html/200601\372.html
使用 JSF 架构q行设计
http://www.zebcn.com/html/200601\376.html
用java做的滚动的正弦曲U?
http://www.zebcn.com/html/200601\378.html
EJB3.0和Spring比较
http://www.zebcn.com/html/200601\379.html
Struts 中常见错?
http://www.zebcn.com/html/200601\380.html
漫谈Java数据库存取技?
http://www.zebcn.com/html/200601\381.html
Java多线E程序设?
http://www.zebcn.com/html/200601\385.html
JAVA中的旉操作
http://www.zebcn.com/html/200601\386.html
12个最重要的J2EE最?jng)_?
http://www.zebcn.com/html/200601\389.html
Java中的异步|络~程
http://www.zebcn.com/html/200601\394.html
Java I/O重定?
http://www.zebcn.com/html/200601\395.html
构徏高性能J2EE应用?0个技?
http://www.zebcn.com/html/200601\397.html
javaE序得到域名对应的所有IP地址
http://www.zebcn.com/html/200601\398.html
Java语言~程中更新XML文的常用方?
http://www.zebcn.com/html/200601\401.html
HTTP代理如何正确处理Cookie
http://www.zebcn.com/html/200601\405.html

作者:(x) fafile 2006-5-18 09:57 回复此发a


3
回复QJava_֓文章攉

JavaMail 发送HTML邮g
http://www.zebcn.com/html/200602\411.html
JSP数据cd
http://www.zebcn.com/html/200602\412.html
Java5 多线E实?
http://www.zebcn.com/html/200602\415.html
JDK5.0?1个主要新特征
http://www.zebcn.com/html/200602\419.html
q用cd机制简化Struts应用E序开?
http://www.zebcn.com/html/200602\420.html
?nbsp;Struts 实现动态单选按?
http://www.zebcn.com/html/200602\421.html
JDO技术分析及(qing)企业应用研究
http://www.zebcn.com/html/200602\422.html
一个J2EE目的最工具集
http://www.zebcn.com/html/200602\425.html
一个实现MD5的简z的javac?
http://www.zebcn.com/html/200602\429.html
服务器与览器的?x)?
http://www.zebcn.com/html/200602\434.html
使用Spring JMS化异步消息处?
http://www.zebcn.com/html/200603\443.html
采用HttpServlet 实现web文g下蝲
http://www.zebcn.com/html/200603\444.html
Spring AOP实际应用一?
http://www.zebcn.com/html/200603\445.html
JNI中文处理问题结
http://www.zebcn.com/html/200603\446.html
java获取windowspȝ|卡mac地址
http://www.zebcn.com/html/200603\454.html
Swing vs. SWT 之调用堆栈性能比较
http://www.zebcn.com/html/200603\462.html
Using SVN with Ant
http://www.zebcn.com/html/200603\463.html
mudE序?qing)内附的dom4j解析xml源代?
http://www.zebcn.com/html/200603\464.html
myeclipse中J2EE目之间的组l结?
http://www.zebcn.com/html/200603\465.html
初学者如何开发出高质量的J2EEpȝ
http://www.zebcn.com/html/200603\467.html
WebLogic Server 理最?jng)_?
http://www.zebcn.com/html/200603\474.html
WebLogic Server 性能调优
http://www.zebcn.com/html/200603\475.html
化WebLogic 8.1目的配|?
http://www.zebcn.com/html/200603\476.html
WebLogic域配|策?手动和模杉K项
http://www.zebcn.com/html/200603\477.html
JDBC中获取数据表的信?
http://www.zebcn.com/html/200603\479.html
Java 开发中遇到的ؕ码问?
http://www.zebcn.com/html/200603\484.html
易的http客户端附源代?
http://www.zebcn.com/html/200603\486.html
JDBC 4.0规范之目?
http://www.zebcn.com/html/200603\487.html
java的各U排序算?
http://www.zebcn.com/html/200603\495.html
用Java实现Web服务?
http://www.zebcn.com/html/200603\496.html
使用DBMS存储q程
http://www.zebcn.com/html/200603\497.html
Java剖析工具YourKit Java Profiler 6.0-EAP1 发布
http://www.zebcn.com/html/200603\3253.html
用Java快速开发Linux GUI应用
http://www.zebcn.com/html/200603\3260.html
java 理论与实? ?nbsp;typedef 反模?
http://www.zebcn.com/html/200604\3262.html
使用 Struts Validator (1)
http://www.zebcn.com/html/200604\3263.html
使用 Struts Validator (2)
http://www.zebcn.com/html/200604\3264.html
使用 Struts Validator (3)
http://www.zebcn.com/html/200604\3265.html
使用 Struts Validator (4)
http://www.zebcn.com/html/200604\3266.html
使用 Struts Validator (5)
http://www.zebcn.com/html/200604\3267.html
使用 Struts Validator (6)
http://www.zebcn.com/html/200604\3268.html
查询数据库后q回Iterator
http://www.zebcn.com/html/200604\3278.html
DOM属性用法速查手册
http://www.zebcn.com/html/200604\3279.html
论J2EEE序员的武功修ؓ(f)
http://www.zebcn.com/html/200604\3280.html
让window服务q程中自动加载MYSQL服务
http://www.zebcn.com/html/200604\3287.html
J2EE应用E序异常处理框架
http://www.zebcn.com/html/200604\3289.html
Java2下Applet数字{֐具体实现Ҏ(gu)
http://www.zebcn.com/html/200604\3290.html
使用tomcat4.1.31和mysql 配置数据?
http://www.zebcn.com/html/200604\3291.html
用java得到本机所有的ip地址
http://www.zebcn.com/html/200604\3292.html
使用Socketq接I越CMWAP代理
http://www.zebcn.com/html/200604\3293.html
JavadExcel方式Ҏ(gu)
http://www.zebcn.com/html/200604\3294.html



jacksontoto 2007-08-15 08:50 发表评论
]]>
几种js实现的动态多文g上传http://www.aygfsteel.com/jackson110/archive/2007/08/15/136808.htmljacksontotojacksontotoWed, 15 Aug 2007 00:38:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/08/15/136808.htmlhttp://www.aygfsteel.com/jackson110/comments/136808.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/08/15/136808.html#Feedback2http://www.aygfsteel.com/jackson110/comments/commentRss/136808.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/136808.html 方式一Q事先写好多个input.在点?yn)L才显C。也是说上传的最大个数是写死?jin)的?br> html

<p>
<a href='#' onclick='javascript:viewnone(more1)'> d附g </a>
<div id='more1' style='display:none'>
<input type="file" name="attach1" size="50"javascript:viewnone(more2)>
</span>
</div>
<div id='more2' style='display:none'>
<input type="file" name="attach2" size="50"'>
</div>
</p>

js

<SCRIPT language="javascript">
function viewnone(e){
    e.style.display=(e.style.display=="none")?"":"none";
  }
</script>

方式?q种方式的动态多文g上传是实C(jin)的,很简单的Q不说废话看code
html

<input type="button" name="button" value="d附g" onclick="addInput()">
<input type="button" name="button" value="删除附g" onclick="deleteInput()">
<span id="upload"></span>

js

<script type="text/javascript">
var attachname = "attach";
var i=1;
function   addInput(){
if(i>0){
var attach = attachname + i ;
if(createInput(attach))
                      i=i+1;
              }
          } 
function deleteInput(){
if(i>1){
                    i=i-1;
if(!removeInput())
                        i=i+1;
                }
          } 
function createInput(nm){   
var  aElement=document.createElement("input");   
             aElement.name=nm;
             aElement.id=nm;
             aElement.type="file";
             aElement.size="50";
//aElement.value="thanks";   
//aElement.onclick=Function("asdf()");  
if(document.getElementById("upload").appendChild(aElement) == null)
return false;
return true;
          }  
function removeInput(nm){
var aElement = document.getElementById("upload");
if(aElement.removeChild(aElement.lastChild) == null)
return false;
return true;   
          }  
</script>

方式三:(x)动态多文g上传Q只是在oFileInput.click();q个地方Q这样做׃能上传这个文件了(jin)Q因为发现它在上传之时就把这个input中的文g|空?jin)。很可能是ؓ(f)?jin)安全着惛_Q?br>另外q有一点就是说Qclick()只有在ie中才能正常运行?br>虽说q种方式最l没能实C传,但还是留下来参考,看看是否有h可以真正实现上传?br> html

<A href="javascript:newUpload();">d附g</A>
<TABLE width="100%" border="0" cellpadding="0" cellspacing="1">
<TBODY id="fileList"></TBODY>
</TABLE>
<DIV id="uploadFiles" style="display:block"></DIV>

js

<SCRIPT language="javascript">
//---新徏上传
function newUpload(){
var oFileList = document.getElementById("fileList");
var fileCount = oFileList.childNodes.length + 1;
var oFileInput = newFileInput("upfile_" + fileCount);
if(selectFile(oFileInput)){
            addFile(oFileInput);
        }
    }
//----选择文g
function selectFile(oFileInput){
var oUploadFiles = document.getElementById("uploadFiles");
        oUploadFiles.appendChild(oFileInput);
        oFileInput.focus();
        oFileInput.click();//不能q样做,可能是ؓ(f)?jin)安全着惛_Q?br>var fileValue = oFileInput.value;
if(fileValue == ""){
            oUploadFiles.removeChild(oFileInput);
return false;
        }
else
return true;
    }
//---新徏一个文件显C列?br>function addFile(oFileInput){
var oFileList = document.getElementById("fileList");
var fileIndex = oFileList.childNodes.length + 1;
var oTR  = document.createElement("TR");
var oTD1 = document.createElement("TD");
var oTD2 = document.createElement("TD");
        oTR.setAttribute("id","file_" + fileIndex);
        oTR.setAttribute("bgcolor","#FFFFFF");
        oTD1.setAttribute("width","6%");
        oTD2.setAttribute("width","94%");
        oTD2.setAttribute("align","left");
        oTD2.innerText = oFileInput.value;
        oTD1.innerHTML = '<A href="javascript:removeFile('+ fileIndex + ');">删除</A>';
        oTR.appendChild(oTD1);
        oTR.appendChild(oTD2);
        oFileList.appendChild(oTR);
    }
//---U除上传的文?nbsp;
function removeFile(fileIndex){
var oFileInput = document.getElementById("upfile_" + fileIndex);
var oTR        = document.getElementById("file_" + fileIndex);
        uploadFiles.removeChild(oFileInput);
        fileList.removeChild(oTR);
    }
//---创徏一个file input对象q返?br>function newFileInput(_name){
var oFileInput  = document.createElement("INPUT");
        oFileInput.type = "file";
        oFileInput.id = _name;
        oFileInput.name = _name;
        oFileInput.size="50";
//oFileInput.setAttribute("id",_name);
//oFileInput.setAttribute("name",_name);
//oFileInput.outerHTML = '<INPUT type=file id=' + _name + ' name=' + _name + '>';
//alert(oFileInput.outerHTML);
return oFileInput;
    }
</SCRIPT>

posted on 2007-01-26 17:21 重归本垒QBNBNQ?/a> 阅读(1656) 评论(4) ~辑 收藏 引用 所属分c? JS

评论
# re: 几种js实现的动态多文g上传 2007-01-27 13:20 施伟

呵呵Q我的方法不知道和你的三U方法有没有可比性,个h感觉q(sh)错!
做一?d附g 然后做一个type为file的input框,把此框和span定位重叠h 把file框透明度设|ؓ(f)0 卛_全看不到Q但是确实存在。这个时候点span的时候就是在点这个file?但是看不到file框子 是不是实C(jin)呢? 然后再结合你W二U的方式l框~号 动态增加就可以实现多文件上传了(jin) ?
呵呵 我在我的E序里面q样实现?很好?如果有兴讨论到我blog留言 或者发邮gl我?多交。。?
回复 更多评论

# re: 几种js实现的动态多文g上传 2007-01-29 18:00 重归本垒QBNBNQ?/a>

@施伟
呵呵Q施伟,你这样做Q如果实C(jin)Q那么比我的Ҏ(gu)更胜一{了(jin)Q我以前也这栯(g)虑q,只是觉的好麻?ch),而没有去实现它!
另外Q还非常谢谢你能x(chng)我的Qolg!
回复 更多评论

# re: 几种js实现的动态多文g上传 2007-02-12 17:12 路过?/a>

施伟 的做法,是不是还是不能解冻I先选择?jin)一个文Ӟ提交服务器之后这个file input域的值又被自动清I的问题Q?nbsp; 回复 更多评论

# re: 几种js实现的动态多文g上传 2007-06-04 11:28 sangern

W二U方法不?nbsp; 回复 更多评论



jacksontoto 2007-08-15 08:38 发表评论
]]>
~写JSP|站时写的一些工具函?攉)http://www.aygfsteel.com/jackson110/archive/2007/08/03/134249.htmljacksontotojacksontotoFri, 03 Aug 2007 07:07:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/08/03/134249.htmlhttp://www.aygfsteel.com/jackson110/comments/134249.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/08/03/134249.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/134249.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/134249.html[ 2007-7-27 16:28:00 | By: 叶寻?]

初学JSP?写了(jin)一些工具函数因Z太会(x)用JAVA下的正则表达式也只能q么写啦!

发出来让大家批评批评提点意见!有几个函C是自己写的希望爱挑(xi)剌的朋友?

下留?我是新手我怕谁,脸皮不行的h水^也上不去呀.d..

package mxzc.web.strctrl;
public class StringCtrl
{/********************************************
public synchronized String HTMLcode(String TXTcode)   功能:文本替换
public synchronized String Unhtmlcode(String str)   功能:(不完?反文?

替换
public synchronized String Unhtmlcodea(String str)   功能:反文本替?br>public synchronized boolean emailcheck (String email)   功能:(g)查一个字

W串是否W合E-Mail
public synchronized boolean isemailstr(String email)   功能:(g)查一个字

W串是否W合E-Mail
public synchronized boolean isqqstr(String qq)    功能:(g)查一个字W串?

否符合QQ
public synchronized boolean isnumstr(String num)   功能:(g)查一个字W串

是否Z数字?br>public synchronized String userstrlow(String user)   功能:替换用户名中

不合法的部分
public synchronized boolean userstrchk(String user)   功能:(g)查字W串?

否符合用户名法则
public synchronized boolean istelstr(String tel)   功能:(g)查字W串是否

为TEL
public synchronized boolean urlcheck(String url)   功能:(g)查字W串是否

为URL
public synchronized String isotogbk(String iso)    功能:ISO9006-1码{?

为GBK
public synchronized String gbktoiso(String gbk)    功能:GBK码{换ؓ(f)

ISO9006-1
public synchronized String dostrcut(String oldstr,int length)  功能:?

汉字长换?英文按半个字?
public synchronized String inttodateshow(int datenum)   功能:?900q至

旉的秒数换为日期字W串
public synchronized String nowdateshow()    功能:昄当前日期
public synchronized java.util.Date inttodate(int datenum)  功能:秒?

转换为日?br>public synchronized int datetoint()     功能:时间换Z1900q至今的U?

?br>public synchronized int datetoint(java.util.Date d)   功能:时间换Z

1900q至旉的秒?br>public synchronized String overlengthcut(String str,int length)  功能:

截取前几个字W?单位为汉字字?br>public synchronized String replace(String str,String suba,String subb)

功能:字符串替?br>*********************************************/
private static final String isostr="ISO8859-1";
private static final String gbkstr="GBK";
public StringCtrl()
{
}
public synchronized boolean emailcheck (String email)
{
if(email==null)return false;
if(email.length()<6)return false;
if(email.indexOf("@")<2)return false;
if(email.indexOf(".")<4)return false;
if(email.endsWith(".")||email.endsWith("@"))return false;
if(email.lastIndexOf("@")>email.lastIndexOf(".")-1)return false;
if(email.lastIndexOf("@")!=email.indexOf("@"))return false;
String[] lowstr={"\@#","\"","\n","&","\t","\r","<",">","/","\\","#"};
for(int i=0;i<lowstr.length;i++)if(email.indexOf("lowstr")>0)return

false;
return true;
}
public synchronized boolean isemailstr(String email)
{
if(email==null)return false;
if(email.indexOf("@")==-1||email.indexOf(".")==-1||email.length()<6)

return false;
return true;
}
public synchronized boolean isqqstr(String qq)
{
if(qq==null)return false;
if(qq.length()>12)return false;
if(qq.length()<5)return false;
for(int i=0;i<qq.length();i++)
if(!(((int)qq.charAt(i))<=57&&((int)qq.charAt(i))>=48))return false;
return true;
}
public synchronized boolean isnumstr(String num)
{
if(num==null)return false;
if(num.length()<1)return false;
for(int i=0;i<num.length();i++)
if(!(((int)num.charAt(i))<=57&&((int)num.charAt(i))>=48))return false;
return true;
}
public synchronized String userstrlow(String user)
{
String newuserstr=user.trim();
char[] lowstr=

{@#\@#@#,@#\"@#,@#\n@#,@#&@#,@#\t@#,@#\r@#,@#<@#,@#>@#,@#/@#,@#\\@#,@##

@#};
for(int i=0;i<lowstr.length;i++)
newuserstr=newuserstr.replace(lowstr[i],@#+@#);
return newuserstr;
}
public synchronized boolean userstrchk(String user)
{
String newuserstr=user.trim();
char[] lowstr=

{@#\@#@#,@#\"@#,@#\n@#,@#&@#,@#\t@#,@#\r@#,@#<@#,@#>@#,@#/@#,@#\\@#,@##

@#,@#~@#,@#`@#,@#!@#,@#@@#,@#$@#,@#%@#,@#^@#,@#*@#,@#(@#,@#)@#,@#-

@#,@#_@#,@#+@#,@#=@#,@#|@#,@#?@#,@#,@#,@#;@#,@#.@#};
for(int i=0;i<lowstr.length;i++)
newuserstr=newuserstr.replace(lowstr[i],@#+@#);
return (user.equals(newuserstr))?true:false;
}
public synchronized boolean istelstr(String tel)
{
if(tel==null)return false;
if(tel.length()<1)return false;
if(tel.length()>32)return false;
for(int i=0;i<tel.length();i++)
if(!(((int)tel.charAt(i))<=57&&((int)tel.charAt(i))>=48))if(tel.charAt

(i)!=@#-@#)return false;
return true;
}
public synchronized boolean urlcheck(String url)
{
if(url==null)return false;
if(url.length()<10)return false;
String urls=url.toLowerCase();
if(!urls.startsWith("http://"))return false;
if(url.indexOf("<")>0||url.indexOf(">")>0)return false;
return true;
}
public synchronized String isotogbk(String iso)throws Exception
{
 if(iso!=null)return (new String(iso.getBytes(isostr),gbkstr));
 if(iso.length()<1)return "";
 return null;
}
public synchronized String gbktoiso(String gbk)throws Exception
{
 if(gbk!=null)return (new String(gbk.getBytes(gbkstr),isostr));
 if(gbk.length()<1)return "";
 return null;
}
public synchronized String HTMLcode(String TXTcode)
{
 String newstr="";
 if(TXTcode==null)return "";
 newstr=TXTcode;
 newstr=replace(newstr,"&","&amp;");
 newstr=replace(newstr,"\"","&quot;");
 newstr=replace(newstr," ","&nbsp;");
 newstr=replace(newstr,"<","&lt;");
 newstr=replace(newstr,">","&gt;");
 newstr=replace(newstr,"\@#","&#00039;");
 return newstr;
}
public synchronized String Unhtmlcode(String str)
{
 String newstr="";
 if(str==null)return "";
 if(str.length()<1)return "";
 newstr=str;
 newstr=replace(newstr,"&amp;","&");
 //newstr=replace(newstr,"&quot;","\"");
 newstr=replace(newstr,"&nbsp;"," ");
 newstr=replace(newstr,"&quot;","\"");
 //newstr=replace(newstr,"&lt;","<");
 //newstr=replace(newstr,"&gt;",">");
 newstr=replace(newstr,"&#00039;","\@#");
 return newstr;
}
public synchronized String Unhtmlcodea(String str)
{
 String newstr="";
 if(str==null)return "";
 if(str.length()<1)return "";
 newstr=str;
 newstr=replace(newstr,"&amp;","&");
 newstr=replace(newstr,"&quot;","\"");
 newstr=replace(newstr,"&nbsp;"," ");
 newstr=replace(newstr,"&lt;","<");
 newstr=replace(newstr,"&gt;",">");
 newstr=replace(newstr,"&#00039;","\@#");
 return newstr;
}
public synchronized String dostrcut(String oldstr,int length)
{
 int i=0;
 int j=0;
 int k=0;
 String newstr="";
 if(oldstr==null)return "";
 if(length<=0)return "";
 for(i=0;i<oldstr.length();i++)
 {
  if(oldstr.charAt(i)==@#\n@#)j=0;
  else if(((int)(oldstr.charAt(i)))>255)j+=2;
  else j++;
  if((j/2)>=length)
  {
   newstr=newstr.concat(oldstr.substring(k,i)+"\n");
   k=i;
   j=0;
  }
 }
 newstr=newstr.concat(oldstr.substring(k)+"\n");
 return newstr;
}
public synchronized String inttodateshow(int datenum)
{
 int year=0;
 int month=0;
 int day=0;
 int hour=0;
 int minute=0;
 int second=0;
 String datestr="";
 java.util.Date d;
 d=new java.util.Date((long)(datenum)*1000);
 java.util.Calendar ds=java.util.Calendar.getInstance();
 ds.setTime(d);
 year=ds.get(java.util.Calendar.YEAR);
 month=ds.get(java.util.Calendar.MONTH);
 day=ds.get(java.util.Calendar.DATE);
 hour=ds.get(java.util.Calendar.HOUR_OF_DAY);
 minute=ds.get(java.util.Calendar.MINUTE);
 second=ds.get(java.util.Calendar.SECOND);
 datestr=Integer.toString(year)+"/"+Integer.toString(1+month)

+"/"+Integer.toString(day);
 return datestr;
}
public synchronized String nowdateshow()
{
 int year=0;
 int month=0;
 int day=0;
 int hour=0;
 int minute=0;
 int second=0;
 String datestr="";
 java.util.Calendar ds=java.util.Calendar.getInstance();
 year=ds.get(java.util.Calendar.YEAR);
 month=ds.get(java.util.Calendar.MONTH);
 day=ds.get(java.util.Calendar.DATE);
 hour=ds.get(java.util.Calendar.HOUR_OF_DAY);
 minute=ds.get(java.util.Calendar.MINUTE);
 second=ds.get(java.util.Calendar.SECOND);
 datestr=Integer.toString(year)+"/"+Integer.toString(1+month)

+"/"+Integer.toString(day);
 return datestr;
}
public synchronized java.util.Date inttodate(int datenum)
{
 int year=0;
 int month=0;
 int day=0;
 String datestr="";
 java.util.Date d;
 d=new java.util.Date((long)(datenum)*1000);
 return d;
}
public synchronized int datetoint()
{
 java.util.Date d=null;
 long ds=0;
 d=new java.util.Date();
 ds=d.getTime();
 return (int)(ds/1000);
}
public synchronized int datetoint(java.util.Date d)
{
 long ds=0;
 ds=d.getTime();
 return (int)(ds/1000);
}
public synchronized String overlengthcut(String str,int length)
{
 int i=0;
 int j=0;
 if(str==null)return "";
 if(length<0)return "";
 if(str.length()<=length)return str;
 for(i=0;i<str.length();i++)
 {
  if(((int)(str.charAt(i)))>255)j+=2;
  else j++;
  if((j/2)>=length)
  {
   return str.substring(0,i);
  }
 }
 return str;
}
public synchronized String replace(String str,String suba,String subb)
{
String newstr="";
int start=0;
int offset=0;
int subalength=0;
int strlength=0;
if(str==null||suba==null||subb==null)return str;
if(suba.equals(subb))return str;
if(str.length()<suba.length()||str.length()<subb.length())return str;
if(str.length()>0&&suba.length()>0&&subb.length()>0)
{
 subalength=suba.length();
 strlength=str.length();
 while(true)
 {
  if(str.indexOf(suba)<0)break;
  if(offset>strlength)break;
  start=str.indexOf(suba,offset);
  if(start<offset)break;
  newstr=newstr.concat(str.substring(offset,start));
  newstr=newstr.concat(subb);
  offset=start+subalength;
 }
 newstr=newstr.concat(str.substring(offset));
 return newstr;
}
else
{
 return str;
}
}
}



jacksontoto 2007-08-03 15:07 发表评论
]]>
Java中如何正用字体编?/title><link>http://www.aygfsteel.com/jackson110/archive/2007/08/01/133711.html</link><dc:creator>jacksontoto</dc:creator><author>jacksontoto</author><pubDate>Wed, 01 Aug 2007 01:01:00 GMT</pubDate><guid>http://www.aygfsteel.com/jackson110/archive/2007/08/01/133711.html</guid><wfw:comment>http://www.aygfsteel.com/jackson110/comments/133711.html</wfw:comment><comments>http://www.aygfsteel.com/jackson110/archive/2007/08/01/133711.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jackson110/comments/commentRss/133711.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jackson110/services/trackbacks/133711.html</trackback:ping><description><![CDATA[<p>在Java~程中,中文字体~码隑ր了(jin)不少E序员,如果抓住?jin)?jing)响Java中文昄的几个关键因素,问题迎刃而解? <p>Java是目前最行的面向对象的~程语言之一QJava支持UTF-8、ISO-8 <p>859-1、GBK{各U字体编码,可笔者发现Java中字体编码的问题?sh)难倒了(jin)不少E序员,|上虽然也有不少关于在Java中如何正显CZ文的文章Q但都不够全面,W者特意ȝ如下? <p>影响Java中字体编码正显C的有几个因? 1)<a ><b><a ><b>数据?/b></a></b></a>的连接方? 2)|页中用的字体~码; 3)数据库里存放数据的字体编? 4)Java的缺省字体编码。如果在~程中遇C能正显CZ文时Q要先弄清楚以上几项所使用的字体编码,再分析找出原因,卛_解决问题? <p>众所周知QJSP是Java的一U,和网|养I而网也有自q中文~码pȝQ所以JSP处理中文要比UJava的类文g更ؓ(f)ȝ(ch)。本文的试数据库是MySQL3.2Q数据库q接驱动是用org.gjt.mm.mysql.DriverQ这里主要讨论UTF-8和GBK的显C? GB2312是GBK的一个子集,Java中可以用GBK来代替GBpd)。我们先来研IJSP中字体编码问题, 下面W一到第六点是针对JSP?因ؓ(f)从数据库里读Z文数据与写入中文数据有所区别Q咱们分别说明,前三Ҏ(gu)从读取数据库到显C在|页Q后三点是从|页输入数据到存入数据库)Q第七到W九(ji)炚w对纯Java的类文g?以下rs表示ResultSet的一个实例,是执行Select语句之后产生的数据集? <p>一、数据库q接方式使用UTF-8 <p>在连接数据库的驱动后面加上这句参数useUnicode=true&characterEncoding= <p>UTF-8Q例如jdbc:mysql://lo<a ><b>ca</b></a>lhost/DBVF?autoReconnect=true&useUnicode= <p>true&characterEncoding=UTF-8Q从数据库里d中文昄在用GBK的JSP的网里Q如果数据库里存攄字体~码是UTF-8Q在JSP中?str=new String(rs.getBytes(1),"UTF-8")或者str=rs.getString(1)Q可以正显CZ文。如果数据库里存攄是GBK数据Q那么JSP中也要用str=new String(rs.getBytes(1),"GBK")来显C正的中文。值得注意的是如果面使用UTF-8Q数据库里存攄是UTF-8Q也可以用str=new String(rs.getBytes(1),"GBK")正确昄中文。如果网|UTF-8Q而数据库里存攄是GBKQ无法直接显CZ文,需?步{? str=new String(rs.getBytes(1),"GBK"); 再str=new String(str.getBytes("UTF-8"),"GBK")Q才可以正确昄中文? <p>二、数据库q接方式使用GBK <p>在连接数据库的驱动后面加上这句参数useUnicode=true&characterEncoding= <p>GBK,例如jdbc:mysql://localhost/DBVF?autoReconnect=true&UseUnicode=true& <p>characterEncoding=GBKQ从数据库里d中文Q显C在使用GBK的JSP的网里Q如果数据库里存攄字体~码是UTF-8Q在JSP中一定要使用 str=new String(rs.getBytes(1),"UTF-8")Q才正确昄中文。如果数据库里存攄是GBK数据Q那么JSP中也要用str=new String(rs.getBytes(1),"GBK") 或者直接用str=rs.getString(1)Q即可显C正的中文?如果|页是UTF-8Q而数据库里存攄是GBKQ只能用str=new String(rs.getString(1).getBytes("UTF-8"),"GBK")的方法来昄中文; 如果|页是UTF-8Q而数据库里存攄是UTF-8Q可用str=new String(rs.getBytes(1),"GBK") 或者rs.getString(1)Ҏ(gu)来显CZ文? <p>三、用缺省数据库q接方式 <p>q接数据库的驱动后面没有q句参数useUnicode=&characterEncoding=Q例如jdbc:mysql://localhost/DBVF?autoReconnect=trueQ没有参数useUnicode=true&characterEncodingQ表CZ用默认的ISO-8895-1~码? <p>1. 从数据库里读Z文,昄在GBK的网里。如果数据库里存攄字体~码是UTF-8Q在JSP|页中一定要使用语句 str=new String(rs.getBytes(1),"UTF-8") 或者str= new String(rs.getString(1).getBytes("ISO-8859-1"),"UTF-8")Q才可正显CZ文。如果数据库里存攄是GBK数据Q那么JSP中也要用str=new String(rs.getBytes(1),"GBK")或str=new String(rs.getString(1).getBytes("ISO-8859-1"),"GBK") 昄正确的中文? <p>2. 如果|页是UTF-8,不能直接正确昄GBKQ需?步{换,str=new String(rs.getBytes(1),"GBK")Q再str=new String(str.getBytes("UTF-8"),"GBK") 才可以正显CZ文。如果数据库里存的是UTF-8Q直接用str=new String(rs.getBytes(1),"GBK")或者str=new String(rs.getString(1).getBytes("ISO-8859-1"),"GBK")可以显CZ文了(jin)? <p>以上是读取数据库里中文正显C在|页上,下面三点是如何正存入数据库? <p>四、数据库q接方式使用UTF-8~码 <p>JSP中要把网输入的中文存入数据库,通常有一个提?Submit)的过E,是用str=request.getParameter("username")Q然后执行update或者insert语句来存入数据库。如何赋值给str很重要,而且q里中文输入与网|使用的字体编码有兟? <p>1?|页使用UTF-8Q用str= new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF-8")或者str= new String(request.getParameter("username").getBytes(),"UTF-8")Q都可以使得存到数据库里的数据是UTF-8~码? <p>2. |页使用GBKQ用str= new String(request.getParameter("username").getBytes(),"GBK")Q那么存入数据库的是UTF-8~码? <p>3. 值得注意的是使用UTF-8的数据库q接方式不能存得GBK? <p>五、数据库q接方式使用GBK~码 <p>1. 输入使用GBK|页Q存到数据库里是GBK的方? str= new String(request.getParameter("username").getBytes("ISO-8859-1"),"GBK") 或者str= new String(request.getParameter("username").getBytes(),"GBK")? <p>2. |页使用GBKQ想存入UTF-8到数据库里,要分2? 先str=new String(request.getParameter("username").getBytes(),"GBK")Q再str=new String(str.getBytes("UTF-8"),"GBK")卛_? <p>3. |页使用UTF-8Q而且使用str= new String(request.getParameter("username").getBytes("ISO-8859-1"),"GBK") 或者str= new String(request.getParameter("username").getBytes(),"UTF-8")Q那么存到数据库里的数据是UTF-8~码? <p>4. |页使用UTF-8Q而且使用str= new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF-8")Q那么存到数据库里的数据是GBK~码? <p>六、数据库q接方式使用~省Q即不用参数useUnicode和characterEncoding <p>1. |页使用GBKQ如果用str= request.getParameter("username")或者str= new String(request.getParameter("username").getBytes())Q那么在数据库里的数据是GBK码。网用UTF-8 和用str= request.getParameter("username")Q则存入数据库是UTF-8~码? <p>2. 如果使用str= new String(request.getParameter("username").getBytes("ISO-8859-1"))Q那么根据网|供的字体~码而存到数据库里,比如是UTF-8的网,那么存到数据库中是UTF-8~码Q如果用GBK|页Q那么存到数据库里的字就是GBK~码? <p>3. 如果使用str= new String(request.getParameter("username").getBytes("UTF-8"),"UTF-8")q一U组合能存到正确的数据外Q其他存到数据库里的数据则都是ؕ码或者错误码。在q个UTF-8l合的特例中Q网用的是GBKQ则存放到数据库里就是GBKQ网用UTF-8Q那么存到数据库里的是UTF-8? <p>4. |页是GBK的要存得UTF-8Q一定需?? company=new String(request.getParameter("company").getBytes(),"GBK")和company=new String(company.getBytes("UTF-8"))? <p>5. |页是UTF-8的,不能存得GBK在数据库里,一句话Q改变数据库q接方式不能存得GBK码? <p>以上所有的都是ZJSP|页和数据库交换数据Q下面讨Z下纯JAVA~程下的字体~码转换? <p>七、数据库q接方式使用UTF-8~码 <p>1. 数据库里的中文是UTF-8Q可以{换ؓ(f)GBK,但不能把GBK存入数据库? <p>2. 数据库是GBKQ如果{换ؓ(f)UTF-8Q用content=new String(rs.getBytes(2),"GBK")直接content存入数据库就可ؓ(f)UTF-8? <p>八、数据库q接方式使用GBK~码 <p>1. 数据库里的中文是UTF-8Q如果{换ؓ(f)GBKQ用content= new String(rs.getString(2).getBytes(),"UTF-8"),再直接用update或者insert语句插入到数据库Q即存得GBK。如果用content= new String(rs.getString(2).getBytes(),"GBK")或者content= new String(rs.getString(2).getBytes())Q再存入数据库即存得q是UTF-8~码? <p>2. 数据库里的中文是GBKQ如果{换ؓ(f)UTF-8Q用content= new String(rs.getString(2).getBytes("UTF-8"))或者content= new String(rs.getString(2).getBytes("UTF-8"),"GBK")Q再直接使用update或者insert语句插入到数据库,卛_得UTF-8? <p>3. 如果某个String是GBKQ要转换为UTF-8Q也是用content= new String(GBKstr.getBytes("UTF-8"))或者content= new String(GBKstr.getBytes("UTF-8"),"GBK"); 如果某个String是UTF-8Q要转换为GBKQ应该用new String(UTFstr.getBytes("GBK"),"UTF-8")? <p>?ji)、数据库q接方式使用~省,即不跟参? <p>1. str2=new String(GBKstr.getBytes("UTF-8"),"ISO-8859-1")Q可以将数据库里的GBK~码转换为UTF-8? <p>2. dUTF-8然后存入UTF-8Q则用str1=new String(UTFstr.getBytes(),"ISO-8859-1")或者str1=new String(UTFstr.getBytes("GBK"),"ISO-8859-1")? <p>3. 不能实现数据库里的UTF-8转换为GBK? <p>如果采用UTF-8的数据库q接方式或者缺省数据连接方式,那么无法UTF-8转ؓ(f)GBKQ而GBK的数据库q接方式可以实现UTF-8和GBK的相互{换。徏议大安用GBK的数据连接方式?/p><img src ="http://www.aygfsteel.com/jackson110/aggbug/133711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jackson110/" target="_blank">jacksontoto</a> 2007-08-01 09:01 <a href="http://www.aygfsteel.com/jackson110/archive/2007/08/01/133711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Web恶意内容入R分析?qing)应?gu)施之?该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15407.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131138.htmljacksontotojacksontotoWed, 18 Jul 2007 10:50:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131138.htmlhttp://www.aygfsteel.com/jackson110/comments/131138.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131138.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/131138.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/131138.htmlW三步:(x)对动态输出内容编?br>每一个ISO-8859-1字符集中的字W都可以~码Z个数|完整的对应关p请见下面的几个表:(x)

??br> ~码表示?br> ??br> 表现形式
&#00;-
 -
 Unused
 -

 -
 HorizontalTab
 space

 -
 Linefeed
 space
-
 -
 Unused
 -

 -
 Space
 space
!
 -
 Exclamationmark
 !
"
 "
 Quotationmark
 "
#
 -
 Numbersign
 #
$
 -
 Dollarsign
 $
%
 -
 Percentsign
 %
&
 &
 Ampersand
 &
'
 -
 Apostrophe
 '
(
 -
 Leftparenthesis
 (
)
 -
 Rightparenthesis
 )
*
 -
 Asterisk
 *
+
 -
 Plussign
 +
,
 -
 Comma
 ,
-
 -
 Hyphen
 -
.
 -
 Period(fullstop)
 .
/
 -
 Solidus(slash)
 /
0-9
 -
 Digits(0-9)
 0-9
:
 -
 Colon
 :
;
 -
 Semi-colon
 ;
<
 <
 Lessthan
 <
=
 -
 Equalssign
 =
>
 >
 Greaterthan
 >
?
 -
 Questionmark
 ?
@
 -
 Commercialat
 @
A-Z
 -
 UppercaseA-Z
 A-Z
[
 -
 Leftsquarebracket
 [
\
 -
 Reversesolidus(backslash)
 \
]
 -
 Rightsquarebracket
 ]
^
 -
 Caret
 ^
_
 -
 Horizontalbar
 _
`
 -
 Acuteaccent
 `
a-z
 -
 Lowercasea-z
 a-z
{
 -
 Leftcurlybrace
 {
|
 -
 Verticalbar
 |
}
 -
 Rightcurlybrace
 }
~
 -
 Tilde
 ~
-t
 -
 Unused
 -

 Non-breakingspace
¡
 ¡
 Invertedexclamation
 ¡

 
 Centsign
 
n
 n
 Poundsterlingsign
 n
]
 ]
 Generalcurrencysign
 ]

 
 Yensign
 
&brVBar;
 
 Brokenverticalbar
 

 
 Sectionsign
 
t
 t
 UMLaut(dierisis)
 t
©
 ©
 Copyright
 ©
ª
 ª
 Feminineordinal
 ª
J
 J
 Leftanglequote,guillemotleft
 J
R
 R
 Notsign
 R
­
 ­
 Softhyphen
 ­
]
 ]
 ReGISteredtrademark
 ]
t
 t
 Macronaccent
 t

 
 Degreesign
 
u
 u
 Plusorminus
 u

̔
 ̔
 Superscripttwo
 ̔

 
 Superscriptthree
 
´
 ´
 Acuteaccent
 ´
µ
 µ
 Microsign
 µ

 ¶
 Paragraphsign
 ¶
·
 ·
 Middledot
 ·
T
 T
 Cedilla
 T
¹
 ¹
 Superscriptone
 ¹
º
 º
 Masculineordinal
 º

 
 Rightanglequote,guillemotright
 

 
 Fraction(onequarter)
 

 
 Fraction(onehalf)
 
¾
 ¾
 Fraction(threequarters)
 ¾
H
 H
 Invertedquestionmark
 H
À
 À
 CapitalA,graveaccent
 À
Á
 Á
 CapitalA,acuteaccent
 Á
Â
 Â
 CapitalA,circumflexaccent
 Â
Ã
 Ã
 CapitalA,tilde
 Ã
Ä
 Ä
 CapitalA,umlaut(dierisis)
 Ä
Å
 Å
 CapitalA,ring
 Å
Æ
 Æ
 CapitalAEdipthong(ligature)
 Æ
Ç
 Ç
 CapitalC,cedilla
 Ç
È
 È
 CapitalE,graveaccent
 È
É
 É
 CapitaE,acuteaccent
 É
Ê
 Ê
 CapitalE,circumflexaccent
 Ê
&EUML;
 Ë
 CapitalE,umlaut(dierisis)
 Ë
Ì
 Ì
 CapitalI,graveaccent
 Ì
Í
 Í
 CapitalI,acuteaccent
 Í
Î
 Î
 CapitalI,circumflexaccent
 Î
Ï
 Ï
 CapitalI,umlaut(dierisis)
 Ï
Ð
 Ð
 CapitalEth,Icelandic
 Ð
Ñ
 Ñ
 CapitalN,tilde
 Ñ
Ò
 Ò
 CapitalO,graveaccent
 Ò
Ó
 Ó
 CapitalO,acuteaccent
 Ó
Ô
 Ô
 CapitalO,circumflexaccent
 Ô
Õ
 Õ
 CapitalO,tilde
 Õ
Ö
 Ö
 CapitalO,umlaut(dierisis)
 Ö
×
 ×
 Multiplysign
 ×
Ø
 Ø
 CapitalO,slash
 Ø
Ù
 Ù
 CapitalU,graveaccent
 Ù
Ú
 Ú
 CapitalU,acuteaccent
 Ú
Û
 Û
 CapitalU,circumflexaccent
 Û
Ü
 Ü
 CapitalU,umlaut(dierisis)
 Ü
Ý
 Ý
 CapitalY,acuteaccent
 Ý
Þ
 Þ
 CapitalThorn,Icelandic
 Þ
ß
 ß
 Smallsharps,German(szligature)
 ß
à
 à
 Smalla,graveaccent
 à
֙
 ֙
 Smalla,acuteaccent
 ֙
â
 â
 Smalla,circumflexaccent
 â
ã
 ã
 Smalla,tilde
 ã
&aUML;
 ä
 Smalla,umlaut(dierisis)
 ä
å
 å
 Smalla,ring
 å
æ
 æ
 Smallaedipthong(ligature)
 æ
ç
 ç
 Smallc,cedilla
 ç
؈
 ؈
 Smalle,graveaccent
 ؈
é
 é
 Smalle,acuteaccent
 é
^
 ^
 Smalle,circumflexaccent
 ^
ë
 ë
 Smalle,umlaut(dierisis)
 ë
ì
 ì
 Smalli,graveaccent
 ì
T
 T
 Smalli,acuteaccent
 T
î
 î
 Smalli,circumflexaccent
 î
ï
 ï
 Smalli,umlaut(dierisis)
 ï
ð
 ð
 Smalleth,Icelandic
 ð
ñ
 ñ
 Smalln,tilde
 ñ
ò
 ò
 Smallo,graveaccent
 òò
Q(mo)
 Q(mo)
 Smallo,acuteaccent
 Q(mo)
ô
 ô
 Smallo,circumflexaccent
 ô
õ
 õ
 Smallo,tilde
 õ
ö
 ö
 Smallo,umlaut(dierisis)
 ö
÷
 ÷
 Divisionsign
 ÷
ø
 ø
 Smallo,slash
 ø
ù
 ù
 Smallu,graveaccent
 ù
ú
 ú
 Smallu,acuteaccent
 ú
](mi)
 ](mi)
 Smallu,circumflexaccent
 ](mi)
ü
 ü
 Smallu,umlaut(dierisis)
 ü
ý
 ý
 Smally,acuteaccent
 ý
V
 V
 Smallthorn,Icelandic
 V
ÿ
 ÿ
 Smally,umlaut(dierisis)
 ÿ

Ҏ(gu)上表Q我们来?个应用实例:(x)

© 2000 Some Co., Inc.Q用©表示版权标识信息?

© 2000 Some Co., Inc.Q用©同样标识版权标识信息?

  对不被信ȝ数据q行~码要优?sh)过滤不被信ȝ数据。在客户端浏览器需要显CZ些特D字W的情况下,q种处理方式?x)恢复特D字W的庐山真面目。当?dng)?gu)有不被信ȝ数据q行~码Q是个相当耗费资源的工作。根据需要,W(xu)eb开发者可以在~码和过?U方法中q行权衡Q选择一U或者؜合用?

该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15407.html



jacksontoto 2007-07-18 18:50 发表评论
]]>
Web恶意内容入R分析?qing)应?gu)施之?/title><link>http://www.aygfsteel.com/jackson110/archive/2007/07/18/131137.html</link><dc:creator>jacksontoto</dc:creator><author>jacksontoto</author><pubDate>Wed, 18 Jul 2007 10:49:00 GMT</pubDate><guid>http://www.aygfsteel.com/jackson110/archive/2007/07/18/131137.html</guid><wfw:comment>http://www.aygfsteel.com/jackson110/comments/131137.html</wfw:comment><comments>http://www.aygfsteel.com/jackson110/archive/2007/07/18/131137.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jackson110/comments/commentRss/131137.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jackson110/services/trackbacks/131137.html</trackback:ping><description><![CDATA[<p>W二步:(x)鉴别Ҏ(gu)的字W?br>  什么是Ҏ(gu)字符QHTML定义如下Q特D字W就是那些能够媄(jing)响页面显C效果的字符。依据上下文的不同,Ҏ(gu)字符也会(x)有所不同。下面我们来分类看看Q? <p>?在块U别元素所包含的内容中应考虑的特D字W有Q? <p><Q引入一个标? <p>&Q引入一个字W实? <p>>Q结束一个标? <p>?在属性g应考虑的特D字W有Q? <p>"Q在以双引号包裹属性值的情况下,"标记?jin)属性值的l尾? <p>'Q在以单引号包裹属性值的情况下,'标记?jin)属性值的l尾? <p>I白字符Q在属性值没有被M引号包裹的情况下Q空白字W标C(jin)属性值的l尾Q比如空根{tab? <p>&Q当需要在属性g引入字符实体Ӟ需要?amp;? <p>?搜烦(ch)引擎pȝ?x)在搜?ch)l果面中包含一个再ơ运行搜索的链接Q这个链接中?x)包含编码过的搜索查询字W串。这U情况下应考虑的特D字W有Q? <p>I格、tab以及(qing)换行W:(x)它们标记?jin)URL的结? <p>&Q它标记一个字W实体,或者一个独立的CGI参数? <p>非ASCII字符Q就是ISO-8859-1~码中ASCII码大?28的字W,它们不允许在URL中用? <p>%Q无论服务器对由escape~码的HTTP参数如何解码Q都必须qo(h)出字W?? <p>??之间的内容中应考虑的特D字W有Q分P圆括P大括号以?qing)换行符? <p>?在服务器端脚本中应考虑的特D字W有Q! <p>?其他情况下应考虑的特D字W有Q?。但注意Q现有的d事gq没有利用过q个字符Q但作ؓ(f)一个全面考虑Q这里还是列出来? <p>  另外Q我们还要重视一U情况:(x)其他附加字符也可能包含在Ҏ(gu)字符列表中。MQW(xu)eb开发者必d应用E序的输入内容进行检查,以确定哪些字W会(x)影响E序的执行?<br>该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15408.html</p><img src ="http://www.aygfsteel.com/jackson110/aggbug/131137.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jackson110/" target="_blank">jacksontoto</a> 2007-07-18 18:49 <a href="http://www.aygfsteel.com/jackson110/archive/2007/07/18/131137.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Web恶意内容入R分析?qing)应?gu)施之一 该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15409.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131136.htmljacksontotojacksontotoWed, 18 Jul 2007 10:49:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131136.htmlhttp://www.aygfsteel.com/jackson110/comments/131136.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131136.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/131136.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/131136.html在各UInternetd行ؓ(f)中,通过Web方式侵入pȝ造成信息泄漏、数据丢q事g非常普遍。例如,d者在面表单中输入恶意内容,l过输入(g)查,dpȝ。ؓ(f)此,W(xu)eb开发者应采取有效的措施从信息采集的入口处堉|恶意内容的进入。本文将对这斚w的问题进行分析,q提供几U应Ҏ(gu)法?

问题分析

  Web面包含文本和HTML标记Q它们由服务器徏立,被客L(fng)解释。HTML标记一般被服务器特D对待。例如,“<”一般指CZ个HTML标记的开始,“<P>”可以媄(jing)响页面的昄格式Q<Script>可以脚本代码引入浏览器而执行?

  对于?rn)态页面,服务器可以完全控制它在客L(fng)如何解释。但是对于动态页面,服务器就不可能完全控制它在客L(fng)的解释行Z(jin)。这样就产生?jin)问题?x)如果动态页面中包含?jin)不可信的内容,那么无论是服务器端还是客L(fng)Q就不能保证是否?x)发生安全问题?

  现在Q几乎所有的商用Web服务器就?x)徏立动态页面。最典型的一个例子就是我们经常要使用的搜索引擎,它接受用L(fng)查询内容后,搜烦(ch)数据库,然后动态内容写入一个页面模板,最后显C给用户包含搜烦(ch)l果的页面。这U情况下Q检查动态内Ҏ(gu)否包含了(jin)Ҏ(gu)字符非帔R要,例如“<”。如果包含了(jin)Ҏ(gu)字符Q用L(fng)的浏览器可能将之误解ؓ(f)HTML标记或者引入执行程序,而不是当做文本信息显C出来。危险也׃生于此!如果不对动态页面进行特D字W的(g)查,那么d者就有可能在交互面的输入表单中写入些特D字W串Q从而导致输出页面执行非法行为。这U例子很多,比如我们~写一个留a,却不对输入内容进行特D字W的校验Q那么攻击者就有可能填写特D字W,最l导致留aK面的非正常工作,例如填写一D|意代码:(x)d@环JavaScript脚本、重复打开H口的JavaScript脚本?

应对措施分析

  通常Q不被信ȝ内容主要来自以下几个斚wQURL参数Q表单输入元素,Cookies和数据库查询。要减轻q些斚w可能D的攻击,采取如下的步骤:(x)

1、ؓ(f)每个由服务器产生的Web面明确地设|字W集~码

2、鉴别特D的字符

3、对动态输出内容编?

4、过滤动态输出内容中的特D字W?

5、检查cookies ?

以下详细分析q?个步骤?

W一步:(x)明确地设|字W集~码

字符集编码就是页面的字符~码体系Q在览器中可以通过“查?~码”来转换Q?

  很多Web面都省略了(jin)字符集编码设|,也就是说在页面源代码头部HTTP一节中没有定义charset参数。早期的HTML版本中,如果没有定义charset参数Q字W集~码默认ؓ(f)ISO-8859-1。但实际上,许多览器都有各自的默认字符集编码。因此,HTML版本4规定Q如果没有指定charset参数QQ何可能的字符集编码都可以使用Q这׃赖于用户的浏览器U类?jin)?

 如果Web服务器不能指定用哪个字W集~码Q那么它?yu)׃能区分出?gu)字符。没有指定字W集~码的Web面之所以可以在大多数时间中工作良好Q这是因为在大多数的字符集编码类别中Q同一字符对应一个小?28的字节倹{对于大?28的特D字W,例如“<”,采?6位字W编码方案处理。一些浏览器能够识别q执行这U编码方案,但同Ӟd者也可能据此使用恶意脚本Q防范隑ֺ加大Q因为服务器可能完全不能?jin)解哪个字节代表哪个?gu)字符。例如,字符集UTF-7为“<”和?gt;”提供了(jin)可选编码,几种行的浏览器一般将它们看做标记的v始和l束字符。ؓ(f)?jin)不造成服务器和客户端的字符~码的不一_(d)W(xu)eb服务器应该明设|字W集Q以认插入的数据是否ؓ(f)Ҏ(gu)字符~码的后l字节。比如,下面的代码强行设|了(jin)面使用ISO-8859-1字符集编码:(x)

QHTML>
QHEAD>
QMETA http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
QTITLE>HTML SAMPLEQ?TITLE>
Q?HEAD>
QBODY>
QP>This is a sample HTML page
Q?BODY>
Q?HTML>

该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15409.html



jacksontoto 2007-07-18 18:49 发表评论
]]>
Win2003完美配置Apache+IIS+Tomcat多站?该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15431.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131134.htmljacksontotojacksontotoWed, 18 Jul 2007 10:46:00 GMThttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131134.htmlhttp://www.aygfsteel.com/jackson110/comments/131134.htmlhttp://www.aygfsteel.com/jackson110/archive/2007/07/18/131134.html#Feedback0http://www.aygfsteel.com/jackson110/comments/commentRss/131134.htmlhttp://www.aygfsteel.com/jackson110/services/trackbacks/131134.html本来以ؓ(f)上一ơ的配置搞定了(jin)Q结果本地测试好好的Q到?jin)服务器上调试就完蛋了(jin),本地只测试?jin)一个ASP站和一个JSP站,而实际情冉|多个asp站和jsp站,又试?jin)两ơ还是不行,l于在第三次试后搞定了(jin)Q写下来做个U念?

  W一ơ尝试用:(x)

<VirtualHost *:80>
ServerAdmin feifei0658@sina.com
ServerName www.5hope.com
DcumentRoot "G:\5hope
DirectoryIndex index.html index.htm index.asp
ProxyPass / http://www.5hope.com:88/
ProxyPassReverse / www.5hope.com:88/
</VirtualHost>

<VirtualHost *:80>
ServerAdmin feifei0658@sina.com
ServerName www.shundabanjia.com
DocumentRoot "G:\wuyubing\www"
DirectoryIndex index.html index.htm index.asp
ProxyPass / http://www.shundabanjia.com:88/
ProxyPassReverse / http://www.shundabanjia.com:88/
</VirtualHost>

  本以栯|多站点搞定了(jin)Q结果发现只识别W一个站点,讉K别的站点都是q个站的内容Q折腾了(jin)一上午Q没成功?

  W二ơ尝试用:(x)

<VirtualHost *:80>
#d?jin)这个属?*********
ProxyPreserveHost On
ServerAdmin feifei0658@sina.com
ServerName www.shundabanjia.com
DocumentRoot "G:\wuyubing\www"
DirectoryIndex index.html index.htm index.asp
ProxyPass / http://www.shundabanjia.com:88/
ProxyPassReverse / http://www.shundabanjia.com:88/
</VirtualHost>

LoadModule jk_module modules/mod_jk.so
JkWorkersFile "D:\tomcat5.0.28\conf\workers.properties"
<VirtualHost *:80>
ServerAdmin feifei0658@sina.com
ServerName www.openria.cn
DirectoryIndex index.html index.htm index.jsp
JkMount /* ajp13
JkAutoAlias "D:\tomcat-5.0.28\Webapps\ria"
<Directory "D:\tomcat-5.0.28\webapps\ria">
Options Indexes FollowSymLinks
allow from all
</Directory>
</VirtualHost>

  q回l过查官方资料,发现?jin)一个属性,叫ProxyPreserveHost OnQ试?jin)一下,是可以用实现多个虚拟的asp站点?jin),但是和我的tomcat站点定义冲突Q访问不?jin)jsp站,又不行,只好再找?

  W三ơ尝试用:(x)

NameVirtualHost *:80

<VirtualHost *:80>
ProxyPreserveHost On
ServerAdmin feifei0658@sina.com
ServerName www.shundabanjia.com
DocumentRoot "G:\wuyubing\www"
DirectoryIndex index.html index.htm index.asp
ProxyPass / http://www.shundabanjia.com:88/
ProxyPassReverse / http://www.shundabanjia.com:88/
</VirtualHost>

LoadModule jk_module modules/mod_jk.so
JkWorkersFile "D:\tomcat5.0.28\conf\workers.properties"
<VirtualHost *:80>
ServerAdmin feifei0658@sina.com
ServerName www.openria.cn
DirectoryIndex index.html index.htm index.jsp
JkMount /* ajp13
JkAutoAlias "D:\tomcat-5.0.28\webapps\ria"
<Directory "D:\tomcat-5.0.28\webapps\ria">
Options Indexes FollowSymLinks
allow from all
</Directory>
</VirtualHost>

  l过反复看文档,q回l于搞定?jin),原来是没有?Use name-based virtual hosting."打开Q去掉NameVirtualHost *:80前面?号就可以?jin),真是晕啊?

  ȝ成功?jin),看来有问题还需要看官方资料Q网友的资料q是不完整啊Q通过自己的努力,发现新的U烦(ch)Q?

ProxyPreserveHost On
NameVirtualHost *:80

  q也是自q收获啊,希望q些l历能帮助需要他的h?

  再次?jin)祝一下,自己的网站终于要开通了(jin)Q欢q访问:(x)www.openria.cn

该文章{载自1024kQhttp://www.1024k.cn/web/2007/200701/15431.html



jacksontoto 2007-07-18 18:46 发表评论
]]>
վ֩ģ壺 | ն| | | Զ| | ά| Ұ| | ƽ| | Ҧ| ̳| | | | ̫| ˮ| ƺ| Ԫ| üɽ| | ֽ| | | կ| | | ˺| ˮ| ǭ| | | | | | | | | | |