﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-叶明的javablog-随笔分类-jsp学习</title><link>http://www.blogjava.net/guming123416/category/6969.html</link><description>java学习天堂,个人关于JAVA的论坛bbs.javaworker.cn,欢迎大家访问</description><language>zh-cn</language><lastBuildDate>Wed, 29 Aug 2007 04:41:06 GMT</lastBuildDate><pubDate>Wed, 29 Aug 2007 04:41:06 GMT</pubDate><ttl>60</ttl><item><title>手把手教你制作Google Sitemap(详细制作教程和协议讲解)</title><link>http://www.blogjava.net/guming123416/archive/2007/08/28/140579.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Tue, 28 Aug 2007 08:36:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2007/08/28/140579.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/140579.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2007/08/28/140579.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/140579.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/140579.html</trackback:ping><description><![CDATA[<p style="TEXT-INDENT: 2em">Google SiteMap Protocol是Google自己推出的一种站点地图协议，此协议文件基于早期的robots.txt文件协议，并有所升级。在Google官方指南中指出加入了Google SiteMap文件的网站将更有利于Google网页爬行机器人的爬行索引，这样将提高索引网站内容的效率和准确度。文件协议应用了简单的XML格式，一共用到6个标签，其中关键标签包括链接地址、更新时间、更新频率和索引优先权。</p>
Google SiteMap文件生成后格式如下： <xmp><urlset xmlns="http://www.google.com/schemas/sitemap
/0.84">
<url>
<loc>http://duduwolf.winzheng.com</loc>
<lastmod>2005-06-03T04:20-08:00</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://duduwolf.winzheng.com/post/140.html</loc>
<lastmod>2005-06-02T20:20:36Z</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
</urlset>
</xmp>XML标签
<ul>
    <li>changefreq:页面内容更新频率。
    <li>lastmod:页面最后修改时间
    <li>loc:页面永久链接地址
    <li>priority:相对于其他页面的优先权
    <li>url:相对于前4个标签的父标签
    <li>urlset:相对于前5个标签的父标签 </li>
</ul>
我将一句一句分解讲解这个xml文件的每一个标签：
<ol>
    <li>&lt;urlset xmlns="http://www.google.com/schemas/sitemap/0.84"&gt;<br>这一行定义了此xml文件的命名空间，相当于网页文件中的&lt;html&gt;标签一样的作用。
    <li><xmp><url></xmp>这是具体某一个链接的定义入口，你所希望展示在SiteMap文件中的每一个链接都要用&lt;url&gt;和&lt;/url&gt;包含在里面，这是必须的。
    <li><xmp><loc>http://duduwolf.winzheng.com</loc></xmp>用&lt;loc&gt;描述出具体的链接地址，这里需要注意的是链接地址中的一些特殊字符必须转换为XML(HTML)定义的转义字符，如下表：
    <table cellSpacing=0 cellPadding=2 border=1>
        <tbody>
            <tr>
                <th colSpan=2 rowSpan=2>字符</th>
                <th colSpan=2>转义后的字符</th>
            </tr>
            <tr>
                <th>HTML字符</th>
                <th>字符编码</th>
            </tr>
            <tr>
                <td noWrap width=125>and(和)</td>
                <td width=125>&amp;</td>
                <td width=75>&amp;amp;</td>
                <td width=75>&#38;</td>
            </tr>
            <tr>
                <td noWrap width=125>单引号</td>
                <td width=125>&amp;apos;</td>
                <td width=75>&amp;apos;</td>
                <td width=75>&#39;</td>
            </tr>
            <tr>
                <td noWrap width=125>双引号</td>
                <td width=125>"</td>
                <td width=75>&amp;quot;</td>
                <td width=75>&#34;</td>
            </tr>
            <tr>
                <td noWrap width=125>大于号</td>
                <td width=125>&gt;</td>
                <td width=75>&amp;gt;</td>
                <td width=75>&#62;</td>
            </tr>
            <tr>
                <td noWrap width=125>小于号</td>
                <td width=125>&lt;</td>
                <td width=75>&amp;lt;</td>
                <td width=75>&#60;</td>
            </tr>
        </tbody>
    </table>
    <li><xmp><lastmod>2005-06-03T04:20:32-08:00</lastmod></xmp>&lt;lastmod&gt;是用来指定该链接的最后更新时间，这个很重要。Google的机器人会在索引此链接前先和上次索引记录的最后更新时间进行比较，如果时间一样就会跳过不再索引。所以如果你的链接内容基于上次Google索引时的内容有所改变，应该更新该时间，让Google下次索引时会重新对该链接内容进行分析和提取关键字。这里必须用<a title="ISO 8601时间格式详细说明" href="http://www.w3.org/TR/NOTE-datetime"><u><font color=#0000ff>ISO 8601</font></u></a>中指定的时间格式进行描述，格式化的时间格式如下：
    <ul style="LIST-STYLE-TYPE: disc">
        <li>年：YYYY(2005)
        <li>年和月：YYYY-MM(2005-06)
        <li>年月日：YYYY-MM-DD(2005-06-04)
        <li>年月日小时分钟：YYYY-MM-DDThh:mmTZD(2005-06-04T10:37+08:00)
        <li>年月日小时分钟秒：YYYY-MM-DDThh:mmTZD(2005-06-04T10:37:30+08:00) </li>
    </ul>
    这里需注意的是TZD，TZD指定就是本地时间区域标记，像中国就是+08:00了
    <li><xmp><changefreq>always</changefreq></xmp>用这个标签告诉Google此链接可能会出现的更新频率，比如首页肯定就要用always(经常)，而对于很久前的链接或者不再更新内容的链接就可以用yearly(每年)。这里可以用来描述的单词共这几个："always", "hourly", "daily", "weekly", "monthly", "yearly"，具体含义我就不用解释了吧，光看单词的意思就明白了。
    <li><xmp>
    <priority>1.0</priority>
    </xmp>&lt;priority&gt;是用来指定此链接相对于其他链接的优先权比值，此值定于0.0 - 1.0之间
    <li>还有&lt;/url&gt;和&lt;/urlset&gt;，这两个就是来关闭xml标签的，这和HTML中的&lt;/body&gt;和&lt;/html&gt;是一个道理
    <li><strong>另外需要注意的是</strong>，这个xml文件必须是utf-8的编码格式，不管你是手动生成还是通过代码生成，建议最好检查一下xml文件是否是utf-8编码，最简单的方法就是用记事本打开xml然后另存为时选择编码(或转换器)为UTF-8。 </li>
</ol>
<img src ="http://www.blogjava.net/guming123416/aggbug/140579.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2007-08-28 16:36 <a href="http://www.blogjava.net/guming123416/archive/2007/08/28/140579.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>经历一些繁忙的工作，开始学习webwork.</title><link>http://www.blogjava.net/guming123416/archive/2007/07/27/132763.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Fri, 27 Jul 2007 05:50:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2007/07/27/132763.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/132763.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2007/07/27/132763.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/132763.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/132763.html</trackback:ping><description><![CDATA[<p>最近由于struts2比较流行起来，我开始想学webwork2买了本书《webwork in action》中文版，但是却发现，讲解按照是2.1.7新的，现在都是2.2.6.了，变化最大(一个简单的helloworld例子：)</p>
<p>web.xml<br>&lt;?xml version="1.0" encoding="GB18030"?&gt;<br>&lt;web-app version="2.4" <br>&nbsp;xmlns="<a href="http://java.sun.com/xml/ns/j2ee">http://java.sun.com/xml/ns/j2ee</a>" <br>&nbsp;xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>" <br>&nbsp;xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/j2ee">http://java.sun.com/xml/ns/j2ee</a> <br>&nbsp;<a href="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd</a>"&gt;<br>&nbsp;&lt;filter&gt;<br>&nbsp;&nbsp;&lt;filter-name&gt;webwork&lt;/filter-name&gt;<br>&nbsp;&nbsp;&lt;filter-class&gt;com.opensymphony.webwork.dispatcher.FilterDispatcher&lt;/filter-class&gt;<br>&nbsp;&lt;/filter&gt;<br>&nbsp;&lt;filter-mapping&gt;<br>&nbsp;&nbsp;&lt;filter-name&gt;webwork&lt;/filter-name&gt;<br>&nbsp;&nbsp;&lt;url-pattern&gt;/*&lt;/url-pattern&gt;<br>&nbsp;&lt;/filter-mapping&gt;<br>&nbsp; &lt;welcome-file-list&gt;<br>&nbsp;&nbsp;&nbsp; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;<br>&nbsp; &lt;/welcome-file-list&gt;<br>&lt;/web-app&gt;<br><br>xwork.xml<br>&lt;!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"<br>"<a href="http://www.opensymphony.com/xwork/xwork-1.0.dtd">http://www.opensymphony.com/xwork/xwork-1.0.dtd</a>"&gt;</p>
<p>&lt;xwork&gt;<br>&nbsp;&lt;include file="webwork-default.xml"&gt;&lt;/include&gt;<br>&nbsp;&lt;package name="default" extends="webwork-default"&gt;<br>&nbsp;&nbsp;&lt;action name="helloWorld" class="cn.javaworker.yeming.action.HelloWorld"&gt;<br>&nbsp;&nbsp;&nbsp;&lt;result name="success"&gt;index.jsp&lt;/result&gt;<br>&nbsp;&nbsp;&nbsp;&lt;result name="input"&gt;hello.jsp&lt;/result&gt;<br>&nbsp;&nbsp;&lt;/action&gt;<br>&nbsp;&lt;/package&gt;<br>&lt;/xwork&gt;<br><br>hello.jsp<br>&lt;%@ taglib prefix="ww" uri="/webwork"%&gt;<br>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;<br>&lt;html&gt;<br>&nbsp; &lt;head&gt;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &lt;title&gt;Enter you name&lt;/title&gt;<br>&nbsp; &lt;/head&gt;<br>&nbsp; <br>&nbsp; &lt;body&gt;<br>&nbsp;&nbsp;&lt;ww:form action="helloWorld"&gt;<br>&nbsp;&nbsp;&nbsp;&lt;ww:textfield label="please enter user name" name="name"&gt;&lt;/ww:textfield&gt;<br>&nbsp;&nbsp;&nbsp;&lt;input&nbsp; type="submit"/&gt;<br>&nbsp;&nbsp;&lt;/ww:form&gt;<br>&nbsp; &nbsp;&lt;form action="helloWorld.action"&gt;<br>&nbsp; &nbsp;&nbsp; please enter you name:&lt;input type="text" name="name" value="&lt;ww:property value="name"/&gt;"/&gt;<br>&nbsp; &nbsp;&nbsp;&lt;input type="submit"&gt;<br>&nbsp; &nbsp;&lt;/form&gt;<br>&nbsp; &lt;/body&gt;<br>&lt;/html&gt;<br><br>index.jsp<br><br>&lt;%@ taglib prefix="ww" uri="/webwork"%&gt;<br>&lt;html&gt;<br>&nbsp;&lt;head&gt;<br>&nbsp;&nbsp;&lt;title&gt;hello page&lt;/title&gt;<br>&nbsp;&lt;/head&gt;<br>&nbsp;&lt;body&gt;<br>&nbsp;&nbsp;The message generated by my first action is :&lt;ww:property value="message"/&gt;<br>&nbsp;&lt;/body&gt;<br>&lt;/html&gt;<br><br>HelloWorld.java<br><br>package cn.javaworker.yeming.action;</p>
<p>import com.opensymphony.xwork.ActionSupport;</p>
<p>/**<br>* @author $author<br>*/<br>@SuppressWarnings("serial")<br>public class HelloWorld extends ActionSupport{<br>&nbsp;<br>&nbsp;private String message;<br>&nbsp;<br>&nbsp;private String name;<br>&nbsp;/**<br>&nbsp; * @see com.opensymphony.xwork.Action#execute()<br>&nbsp; */<br>&nbsp;public String execute() throws Exception<br>&nbsp;{<br>&nbsp;&nbsp;if(name==null||name.equals("")||name.equals("world")){<br>&nbsp;&nbsp;&nbsp;addFieldError("name","blank names or names of 'world' are not allowed!");<br>&nbsp;&nbsp;&nbsp;return INPUT;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;message ="hello "+name+"!\n";<br>&nbsp;&nbsp;message+="this is the time is: "+System.currentTimeMillis();<br>&nbsp;&nbsp;return SUCCESS;<br>&nbsp;}<br>&nbsp;/**<br>&nbsp; * @return the name<br>&nbsp; */<br>&nbsp;public String getName() {<br>&nbsp;&nbsp;return name;<br>&nbsp;}<br>&nbsp;/**<br>&nbsp; * @param name the name to set<br>&nbsp; */<br>&nbsp;public void setName(String name) {<br>&nbsp;&nbsp;this.name = name;<br>&nbsp;}<br>&nbsp;/**<br>&nbsp; * @return the message<br>&nbsp; */<br>&nbsp;public String getMessage() {<br>&nbsp;&nbsp;return message;<br>&nbsp;}</p>
<p><br>}</p>
<img src ="http://www.blogjava.net/guming123416/aggbug/132763.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2007-07-27 13:50 <a href="http://www.blogjava.net/guming123416/archive/2007/07/27/132763.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>StringTokenizer类的使用方法 </title><link>http://www.blogjava.net/guming123416/archive/2006/11/29/84316.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Wed, 29 Nov 2006 04:28:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/11/29/84316.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/84316.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/11/29/84316.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/84316.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/84316.html</trackback:ping><description><![CDATA[
		<div class="postText">
				<strong>StringTokenizer：字符串分隔解析类型<br /></strong>
				<span style="COLOR: indigo">属于：java.util包。</span>
				<br />
				<br />
				<span style="COLOR: blue">１、构造函数。</span>
				<br />
				<ul>
						<br />1. <span style="COLOR: green">StringTokenizer(String str)</span> ：构造一个用来解析str的StringTokenizer对象。java默认的分隔符是“空格”、“制表符(‘\t’)”、“换行符(‘\n’)”、“回车符(‘\r’)”。<br />2. <span style="COLOR: green">StringTokenizer(String str, String delim) </span>：构造一个用来解析str的StringTokenizer对象，并提供一个指定的分隔符。<br />3. <span style="COLOR: green">StringTokenizer(String str, String delim, boolean returnDelims) </span>：构造一个用来解析str的StringTokenizer对象，并提供一个指定的分隔符，同时，指定是否返回分隔符。</ul>
				<br />
				<br />
				<span style="COLOR: blue">２、方法。</span>
				<br />
				<span style="COLOR: red">说明：<br />1. 所有方法均为public；<br />2. 书写格式：［修饰符］　&lt;返回类型&gt; &lt;方法名（［参数列表］）&gt;</span>
				<span style="COLOR: olive">
						<br />如：<br />static int parseInt(String s) 表示：此方法（parseInt）为类方法（static），返回类型为（int），方法所需参数为String类型。</span>
				<br />
				<br />
				<ul>1. <span style="COLOR: green">int countTokens() </span>：返回nextToken方法被调用的次数。如果采用构造函数1和2，返回的就是分隔符数量(例2)。<br />2. <span style="COLOR: green">boolean hasMoreTokens() </span>：返回是否还有分隔符。<br />3. <span style="COLOR: green">boolean hasMoreElements() </span>：结果同2。<br />4. <span style="COLOR: green">String nextToken()</span> ：返回从当前位置到下一个分隔符的字符串。<br />5. <span style="COLOR: green">Object nextElement() </span>：结果同4。<br />6. <span style="COLOR: green">String nextToken(String delim)</span> ：与4类似，以指定的分隔符返回结果。</ul>
				<br />
				<br />
				<span style="COLOR: olive">例子：</span>
				<br />
				<pre>		String s = new String("The Java platform is the ideal platform for network computing");<br />		StringTokenizer st = new StringTokenizer(s);<br />		System.out.println( "Token Total: " + st.countTokens() );<br />		while( st.hasMoreElements() ){<br />			System.out.println( st.nextToken() );<br />　　　　　　　　　　　}<br />结果为：<br />Token Total: 10<br />The<br />Java<br />platform<br />is<br />the<br />ideal<br />platform<br />for<br />network<br />computing<br /></pre>
				<br />
				<span style="COLOR: olive">例2:</span>
				<br />
				<pre>		String s = new String("The=Java=platform=is=the=ideal=platform=for=network=computing");<br />		StringTokenizer st = new StringTokenizer(s,"=",true);<br />		System.out.println( "Token Total: " + st.countTokens() );<br />		while( st.hasMoreElements() ){<br />			System.out.println( st.nextToken() );<br />		}<br />结果为：<br />Token Total: 19<br />The<br />=<br />Java<br />=<br />platform<br />=<br />is<br />=<br />the<br />=<br />ideal<br />=<br />platform<br />=<br />for<br />=<br />network<br />=<br />computing<br /></pre>
		</div>
<img src ="http://www.blogjava.net/guming123416/aggbug/84316.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-11-29 12:28 <a href="http://www.blogjava.net/guming123416/archive/2006/11/29/84316.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>StringBuffer类的使用方法 </title><link>http://www.blogjava.net/guming123416/archive/2006/11/29/84240.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Wed, 29 Nov 2006 02:15:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/11/29/84240.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/84240.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/11/29/84240.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/84240.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/84240.html</trackback:ping><description><![CDATA[
		<div class="postText">
				<strong>StringBuffer：StringBuffer类型<br /><br /></strong>
				<span style="COLOR: darkblue">描述：在实际应用中，经常回遇到对字符串进行动态修改。这时候，String类的功能受到限制，而StringBuffer类可以完成字符串的动态添加、插入和替换等操作。</span>
				<br />
				<br />
				<span style="COLOR: blue">１、构造函数。</span>
				<br />
				<ul>
						<span style="COLOR: green">StringBuffer() </span>：构造一个没有任何字符的StringBuffer类。<br /><span style="COLOR: green">StringBuffer(int length) </span>： ：构造一个没有任何字符的StringBuffer类，并且，其长度为length。<br /><span style="COLOR: green">StringBuffer(String str) </span>：以str为初始值构造一个StringBuffer类。</ul>
				<br />
				<br />
				<span style="COLOR: blue">２、方法。</span>
				<br />
				<span style="COLOR: red">说明：<br />1. 所有方法均为public；<br />2. 书写格式：［修饰符］　&lt;返回类型&gt; &lt;方法名（［参数列表］）&gt;</span>
				<span style="COLOR: olive">
						<br />如：<br />static int parseInt(String s) 表示：此方法（parseInt）为类方法（static），返回类型为（int），方法所需参数为String类型。</span>
				<br />
				<br />
				<ul>
						<span style="COLOR: green">1. StringBuffer append(boolean b) <br />2. StringBuffer append(char c) <br />3. StringBuffer append(char[] str) <br />4. StringBuffer append(char[] str, int offset, int len) <br />5. StringBuffer append(double d) <br />6. StringBuffer append(float f) <br />7. StringBuffer append(int i) <br />8. StringBuffer append(long l) <br />9. StringBuffer append(Object obj) <br />10. StringBuffer append(String str) <br />11. StringBuffer append(StringBuffer sb) </span>
						<br />
						<br />以上的方法都是向字符串缓冲区“追加”元素，但是，这个“元素”参数可以是布尔量、字符、字符数组、双精度数、浮点数、整型数、长整型数对象类型的字符串、字符串和StringBuffer类等。如果添加的字符超出了字符串缓冲区的长度，Java将自动进行扩充。</ul>
				<br />
				<pre>		String question = new String("1+1=");<br />		int answer = 3;<br />		boolean result = (1+1==3);<br /><br />		StringBuffer sb = new StringBuffer();<br />		sb.append(question);<br />		sb.append(answer);<br />		sb.append('\t');<br />		sb.append(result);<br /><br />		System.out.println(sb);<br />结果为：<br />1+1=3   false</pre>
				<br />
				<ul>12. <span style="COLOR: green">int capacity() </span>：返回当前StringBuffer对象（字符串缓冲区）的总空间，而非字符号串的长度。<br />13. <span style="COLOR: green">char charAt(int index) </span>：在当前StringBuffer对象中取索引号为index的字符。第一个字符的索引为“0”<br />14. <span style="COLOR: green">StringBuffer delete(int start, int end) </span>：删除当前StringBuffer对象中以索引号start开始，到end结束的子串。<br />15. <span style="COLOR: green">StringBuffer deleteCharAt(int index) </span>：删除当前StringBuffer对象中索引号为index的字符。<br />16. <span style="COLOR: green">void ensureCapacity(int minimumCapacity)</span> ：重新设置字符号串缓冲区的总空间。如果minimumCapacity大于当前的总空间，则新的空间被设置：一种结果是minimumCapacity；另一种结果是{“老空间”乘2加2}。</ul>
				<br />
				<pre>		StringBuffer sb1 = new StringBuffer(5);<br />		StringBuffer sb2 = new StringBuffer(5);<br /><br />		sb1.ensureCapacity(6);<br />		sb2.ensureCapacity(100);<br /><br />		System.out.println( "sb1.Capacity: " + sb1.capacity() );<br />		System.out.println( "sb2.Capacity: " + sb2.capacity() );<br />结果为：<br />sb1.Capacity: 12<br />sb2.Capacity: 100</pre>
				<br />
				<ul>17. <span style="COLOR: green">void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)</span> ：从当前StringBuffer对象的索引号srcBegin开始，到srcEnd结束的子串，赋值到字符数组dst中，并且从dst的索引号dstBegin开始。</ul>
				<br />
				<pre>		StringBuffer sb = new StringBuffer("I love her!");<br />		char[] i = {'I',' ','l','o','v','e',' ','y','o','u'};<br /><br />		sb.getChars(7,10,i,7);<br /><br />		System.out.println( "sb: " + sb );<br />结果为：sb: I love her!</pre>
				<br />
				<ul>18. <span style="COLOR: green">int indexOf(String str)</span> ：返回当前StringBuffer对象中，第一个满足str子串的位置。<br />19. <span style="COLOR: green">int indexOf(String str, int fromIndex)</span> ：从当前StringBuffer对象的fromIndex开始查找，返回第一个满足str子串的位置。<br /><span style="COLOR: green">20. StringBuffer insert(int offset, boolean b) <br />21. StringBuffer insert(int offset, char c) <br />22. StringBuffer insert(int offset, char[] str) <br />23. StringBuffer insert(int index, char[] str, int offset, int len) <br />24. StringBuffer insert(int offset, double d) <br />25. StringBuffer insert(int offset, float f) <br />26. StringBuffer insert(int offset, int i) <br />27. StringBuffer insert(int offset, long l) <br />28. StringBuffer insert(int offset, Object obj) <br />29. StringBuffer insert(int offset, String str) </span><br /><br />以上的方法都是在当前StringBuffer对象中插入一个元素，在索引号offset处插入相应的值。<br />30. <span style="COLOR: green">int lastIndexOf(String str) </span>：返回当前StringBuffer对象中，最后一个满足str子串的位置。<br />31. <span style="COLOR: green">int lastIndexOf(String str, int fromIndex)</span> ：从当前StringBuffer对象的fromIndex开始查找，返回最后一个满足str子串的位置。<br />32. <span style="COLOR: green">int length() </span>：返回当前StringBuffer对象（字符缓冲区）中，字符串的长度。<span style="COLOR: red">注意：此方法与capacity() 不同。</span><br />33. <span style="COLOR: green">StringBuffer replace(int start, int end, String str)</span> ：替换当前StringBuffer对象的字符串。从start开始，到end结束的位置替换成str。<br />34. <span style="COLOR: green">StringBuffer reverse() </span>：将字符串翻转。</ul>
				<br />
				<pre>		StringBuffer sb = new StringBuffer("0123456789");<br />		System.out.println( "sb.reverse(): " + sb.reverse() );<br />结果为：sb.reverse(): 9876543210</pre>
				<br />
				<ul>35. <span style="COLOR: green">void setCharAt(int index, char ch)</span> ：设置索引号index的字符为ch。<br />36. <span style="COLOR: green">void setLength(int newLength) </span>：重新设置字符串缓冲区中字符串的长度，如果newLength小于当前的字符串长度，将截去多余的字符。</ul>
				<br />
				<pre>		StringBuffer sb = new StringBuffer("0123456789");<br />		sb.setLength(5);<br />		System.out.println( "sb: " + sb );<br />结果为：sb: 01234</pre>
				<br />
				<ul>37.<span style="COLOR: green"> String substring(int start) </span>：取当前StringBuffer对象中，从start开始到结尾的子串。<br />38. <span style="COLOR: green">String substring(int start, int end) </span>：取当前StringBuffer对象中，从start开始到end的子串。<br />39. <span style="COLOR: green">String toString() </span>：将当前StringBuffer对象转换成String对象。</ul>
		</div>
<img src ="http://www.blogjava.net/guming123416/aggbug/84240.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-11-29 10:15 <a href="http://www.blogjava.net/guming123416/archive/2006/11/29/84240.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何使用log4j常见日志</title><link>http://www.blogjava.net/guming123416/archive/2006/07/04/log4j.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Tue, 04 Jul 2006 06:04:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/07/04/log4j.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/56531.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/07/04/log4j.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/56531.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/56531.html</trackback:ping><description><![CDATA[
		<p>log4j.properties  配置文件代码：<br /># Attach appender A1 to root. Set root level to Level.DEBUG.</p>
		<p>log4j.rootLogger=INFO, A1,A4</p>
		<p>log4j.appender.A1=org.apache.log4j.ConsoleAppender<br />log4j.appender.A1.Threshold=ERROR</p>
		<p>log4j.appender.A1.layout=org.apache.log4j.PatternLayout<br />log4j.appender.A1.layout.ConversionPattern=%p [%t] %c{2} (%M:%L) - %m%n</p>
		<p>
				<br />log4j.appender.A4=org.apache.log4j.DailyRollingFileAppender<br />log4j.appender.A4.file=D:\\Java\\logs\\yeming.log<br />log4j.appender.A4.Encoding=GBK<br />log4j.appender.A4.DatePattern='.'yyyy-MM-dd<br />log4j.appender.A4.layout=org.apache.log4j.PatternLayout<br />log4j.appender.A4.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n<br /><br />使用代码：<br />package com.javawoker.yeming.jiemie.database;<br />import java.sql.Connection;<br />import java.sql.SQLException;<br />import javax.naming.Context;<br />import javax.naming.InitialContext;<br />import javax.sql.DataSource;<br />import org.apache.log4j.Logger;<br />/**<br /> <a href="mailto:*@author">*@author</a> 叶明 <a href="mailto:---guming123416@gmail.com">---guming123416@gmail.com</a><br /> <a href="mailto:*@version">*@version</a> $Id: v 1.01 2006/06/38 16:09:14 teodord Exp $<br /> */<br />public class Pubconn {<br /> <br /> /*<br />  * 创建私有变量conn为数据库连接对象中Connection<br />  * 创建私有变量dsye为数据库连接池的DataSource<br />  */<br /> <br /> private Connection conn;<br /> private DataSource dsye;<br /> private static Logger log=Logger.getLogger(Pubconn.class);<br /> /*<br />  * 创建构造函数Pubconn，在建立class中加载数据源的InitialContext<br />  */<br /> public Pubconn()<br /> {<br />  try{<br />   Context initCtx=new InitialContext();<br />   if(initCtx==null)<br />   {<br />    throw new Exception("不能加载文件Context");<br />   }<br />   dsye=(javax.sql.DataSource)initCtx.lookup("jdbc/yeming");<br />  }catch(Exception ex)<br />  {<br />   ex.printStackTrace();<br />   log.error("在加栽数据库连接池时间发生错误"+ex.getMessage());<br />  }<br /> }<br /> /*<br />  * 从连接池中取出一条连接变量<br />  * <br />  */<br /> public Connection getConn()<br /> {<br />  try{<br />   conn=dsye.getConnection();<br />  }catch(SQLException ex)<br />  {<br />   ex.printStackTrace();<br />   log.error("获得连接对象CONN时间发生错误"+ex.getMessage());<br />  }<br />  return conn;<br /> }<br /> /*<br />  * 关闭数据库连接，释放资源<br />  */<br /> public void closeConn(Connection conn)<br /> {<br />  try{<br />   if(conn!=null)<br />   {<br />    conn.close();<br />    conn=null;<br />   }<br />  }catch(SQLException ex)<br />  {<br />   ex.printStackTrace();<br />   log.error("关闭CONN时间发生错误"+ex.getMessage());<br />  }<br /> }</p>
		<p>}<br /></p>
<img src ="http://www.blogjava.net/guming123416/aggbug/56531.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-07-04 14:04 <a href="http://www.blogjava.net/guming123416/archive/2006/07/04/log4j.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>求救</title><link>http://www.blogjava.net/guming123416/archive/2006/06/27/55324.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Tue, 27 Jun 2006 06:13:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/06/27/55324.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/55324.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/06/27/55324.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/55324.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/55324.html</trackback:ping><description><![CDATA[我做报表的时间，发现JSP中路径总是出问题。
总是不明白，用绝对路径和相对路径都找不到这个
文件确实存在，而且路径也是正确的，但是他总是提示：
Class not found when loading object from file : D:\Java\tomcat5.5\webapps\personjob\report\yefirst.jasper 
代码：
File reportFile =new File(application.getRealPath("/report/yefirst.jasper"));
求高手指点以下<img src ="http://www.blogjava.net/guming123416/aggbug/55324.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-06-27 14:13 <a href="http://www.blogjava.net/guming123416/archive/2006/06/27/55324.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>今天又遇到一个问题</title><link>http://www.blogjava.net/guming123416/archive/2006/06/24/54837.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Sat, 24 Jun 2006 02:29:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/06/24/54837.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/54837.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/06/24/54837.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/54837.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/54837.html</trackback:ping><description><![CDATA[我将服务器配置了集群服务后，发现遇见一个问题，两个服务器，两个web应用，这样就造成了用户上传图片的时间只有一个服务处理了，上传的图片就只能到一个web应用中，这样另一个在处理的时间就找不到图片，
为了解决这个问题，我想用两个服务器同是公用一个web应用，但是这样又造成了session总是出现问题，不知道大家有没有比较好的解决方法<img src ="http://www.blogjava.net/guming123416/aggbug/54837.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-06-24 10:29 <a href="http://www.blogjava.net/guming123416/archive/2006/06/24/54837.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于tomcat集群配置问题</title><link>http://www.blogjava.net/guming123416/archive/2006/06/02/49921.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Fri, 02 Jun 2006 05:23:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/06/02/49921.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/49921.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/06/02/49921.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/49921.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/49921.html</trackback:ping><description><![CDATA[今天去客户那里，他说他们的服务器有点慢，要不你帮我配置一个集群服务器，回来后赶紧找资料
我用tomcat5.5.16来配置，看了很多文挡，发现出问题，启动只能有一个，好象是他们的路径重复

现在这个问题解决了
我直接下载解压缩包，这个问题搞定了，可是我发现配置有出问题了。
Tomcat5 +apache 怎么分配 负载平衡以及session共享？

至今天还没有解决啊
看来这次有的忙了啊

呵呵，有朋友知道的话，请您指教。怎么配置tomcat5.5.16 的集群。联系msn：guming123416@hotmail.com 
在这里首先表示谢谢，问题是主要不知道该怎么样启动

朋友推荐我用5.0.28看看


另外换想问问5.0.28 与tomcat5.5.16 到底有什么区别，我的英文一般，没有学过。所以问问
<img src ="http://www.blogjava.net/guming123416/aggbug/49921.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-06-02 13:23 <a href="http://www.blogjava.net/guming123416/archive/2006/06/02/49921.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jsp中，防止表单的重复提交（转） </title><link>http://www.blogjava.net/guming123416/archive/2006/03/23/37054.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Thu, 23 Mar 2006 07:51:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/03/23/37054.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/37054.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/03/23/37054.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/37054.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/37054.html</trackback:ping><description><![CDATA[
		<p>1 javascript ，设置一个变量，只允许提交一次。　 </p>
		<p>　　&lt;script language="javascript"&gt; </p>
		<p>　　 var checkSubmitFlg = false; </p>
		<p>　　 function checkSubmit() { </p>
		<p>　　 if (checkSubmitFlg == true) { </p>
		<p>　　 return false; </p>
		<p>　　 } </p>
		<p>　　 checkSubmitFlg = true; </p>
		<p>　　 return true; </p>
		<p>　　 } </p>
		<p>　　 document.ondblclick = function docondblclick() { </p>
		<p>　　 window.event.returnValue = false; </p>
		<p>　　 } </p>
		<p>　　 document.onclick = function doconclick() { </p>
		<p>　　 if (checkSubmitFlg) { </p>
		<p>　　 window.event.returnValue = false; </p>
		<p>　　 } </p>
		<p>　　 } </p>
		<p>　　&lt;/script&gt; </p>
		<p>　　 </p>
		<p>　　&lt;html:form action="myAction.do" method="post" onsubmit="return checkSubmit();"&gt;　　 </p>
		<p>　　2 还是javascript，将提交按钮或者image置为disable　　 </p>
		<p>　　 &lt;html:form action="myAction.do" method="post" </p>
		<p>　　 onsubmit="getElById('submitInput').disabled = true; return true;"&gt; 　　 </p>
		<p>　　 &lt;html:image styleId="submitInput" src="images/ok_b.gif" border="0" /&gt;　 </p>
		<p>　　 &lt;/html:form&gt;　　 </p>
		<p>　　3 利用struts的同步令牌机制　　 </p>
		<p>　　利用同步令牌（Token）机制来解决Web应用中重复提交的问题，Struts也给出了一个参考实现。 </p>
		<p>　　基本原理：　 </p>
		<p>　　服务器端在处理到达的请求之前，会将请求中包含的令牌值与保存在当前用户会话中的令牌值进行比较，看是否匹配。在处理完该请求后，且在答复发送给客户端之前，将会产生一个新的令牌，该令牌除传给客户端以外，也会将用户会话中保存的旧的令牌进行替换。这样如果用户回退到刚才的提交页面并再次提交的话，客户端传过来的令牌就和服务器端的令牌不一致，从而有效地防止了重复提交的发生。　 </p>
		<p>　　if (isTokenValid(request, true)) { </p>
		<p>　　 // your code here </p>
		<p>　　 return mapping.findForward("success"); </p>
		<p>　　} else { </p>
		<p>　　 saveToken(request); </p>
		<p>　　 return mapping.findForward("submitagain"); </p>
		<p>　　}　 </p>
		<p>　　Struts根据用户会话ID和当前系统时间来生成一个唯一（对于每个会话）令牌的，具体实现可以参考TokenProcessor类中的generateToken()方法。　　 </p>
		<p>　　1. //验证事务控制令牌,&lt;html:form &gt;会自动根据session中标识生成一个隐含input代表令牌，防止两次提交 </p>
		<p>　　2. 在action中：　　 </p>
		<p>　　 //&lt;input type="hidden" name="org.apache.struts.taglib.html.TOKEN" </p>
		<p>　　 // value="6aa35341f25184fd996c4c918255c3ae"&gt; </p>
		<p>　　 if (!isTokenValid(request)) </p>
		<p>　　 errors.add(ActionErrors.GLOBAL_ERROR, </p>
		<p>　　 new ActionError("error.transaction.token")); </p>
		<p>　　 resetToken(request); //删除session中的令牌　　 </p>
		<p>　　3. action有这样的一个方法生成令牌　　 </p>
		<p>　　 protected String generateToken(HttpServletRequest request) {　　 </p>
		<p>　　 HttpSession session = request.getSession(); </p>
		<p>　　 try { </p>
		<p>　　 byte id[] = session.getId().getBytes(); </p>
		<p>　　 byte now[] = </p>
		<p>　　 new Long(System.currentTimeMillis()).toString().getBytes(); </p>
		<p>　　 MessageDigest md = MessageDigest.getInstance("MD5"); </p>
		<p>　　 md.update(id); </p>
		<p>　　 md.update(now); </p>
		<p>　　 return (toHex(md.digest())); </p>
		<p>　　 } catch (IllegalStateException e) { </p>
		<p>　　 return (null); </p>
		<p>　　 } catch (NoSuchAlgorithmException e) { </p>
		<p>　　 return (null); </p>
		<p>　　 } </p>
		<p>　　 } <br /></p>
<img src ="http://www.blogjava.net/guming123416/aggbug/37054.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-03-23 15:51 <a href="http://www.blogjava.net/guming123416/archive/2006/03/23/37054.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Web Tier to Go With Java EE 5: Summary of New Features in JSP 2.1 Technology</title><link>http://www.blogjava.net/guming123416/archive/2006/02/22/31920.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Wed, 22 Feb 2006 02:32:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/02/22/31920.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/31920.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/02/22/31920.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/31920.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/31920.html</trackback:ping><description><![CDATA[<P>The main theme for the Java Platform, Enterprise Edition (Java EE) 5 is ease of development. The platform's web tier contributes significantly to ease of development in two ways. First, the platform now includes the Java Standard Tag Library (JSTL) and <A href="http://java.sun.com/j2ee/javaserverfaces">JavaServer Faces technology</A>. Second, all the web-tier technologies offer a set of features that make development of web applications on Java EE much easier.&nbsp; Some of these features are the following:</P>
<UL>
<LI>A new expression language (EL) syntax that allows deferred evaluation of expressions, enables using expressions to both get and set data and to invoke methods, and facilitates customizing the resolution of a variable or property referenced by an expression<BR>
<LI>Support for resource injection through annotations to simplify configuring access to resources and environment data<BR>
<LI>Complete alignment of JavaServer Faces technology tags and JavaServer Pages (JSP) software code<BR></LI></UL>
<P>In this series of articles, web-tier proponents at Sun introduce the new concepts that every web-application developer should be familiar with to get the most out of the Java EE 5 web-tier technologies. This first article in the series gives an overview of the new features introduced in version 2.1 of JSP technology. </P>
<DIV><B>Background on Alignment of Web-Tier Technologies</B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>Under the auspices of <A href="http://jcp.org/en/jsr/detail?id=245" target=_blank>JSR 245</A> at the Java Community Process (JCP), the main focus of JSP 2.1 technology has been to provide a better alignment with the next release of JavaServer Faces technology, version 1.2. </P>
<P>The misalignment between the two technologies originated with the fact that version 1.0 of JavaServer Faces technology depended on JSP 1.2 technology. The reason is that the JSP 1.2 software was already widely available at the time, and the intention was to make the JavaServer Faces 1.0 interface more accessible to a broader audience. A consequence of this requirement was that JavaServer Faces technology could not take advantage of the EL introduced in the subsequent version of JSP technology, version 2.0. In addition, JSP 2.0 technology could not be modified to accommodate the needs of JavaServer Faces technology. And JSP 1.2 technology does not support an EL. Therefore, JavaServer Faces technology introduced an EL that was suited to its needs as a user interface (UI) component framework. As a result, page authors using JavaServer Faces technology tags with JSP technology code encountered some incompatibilities between the two technologies. </P>
<P>The expert groups have worked together on the upcoming releases of JSP 2.1 and JavaServer Faces 1.2 technologies in Java EE 5 to fix these integration issues and make sure that the two technologies work together seamlessly. One result is that all of the web-tier technologies now share a unified EL, allowing you to mix code from all of these technologies freely and without worry. This article provides an overview of the work that was done to improve the alignment of these technologies.&nbsp; It also explains the other minor improvements that made it into JSP 2.1 technology. </P>
<DIV><B>The Unified Expression Language (EL)</B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>The simple EL included in JSP 2.0 technology offers many advantages to the page author. Using simple expressions, page authors can easily access external data objects from their pages. The JSP technology container evaluates and resolves these expressions as it encounters them. It then immediately returns a response because the JSP request-processing model has only one phase, the <CODE>render</CODE> phase. However, because the request-processing model does not support a <CODE>postback</CODE>, all JSP expressions are read-only. </P>
<P>Unlike JSP technology, JavaServer Faces technology supports a multiphase life cycle. When a user enters values into the JavaServer Faces UI components and submits the page, those values are converted, validated, and propagated to server-side data objects, after which component events are processed. In order to perform all these tasks in an orderly fashion, the JavaServer Faces life cycle is split into separate phases. Therefore, JavaServer Faces technology evaluates expressions at different phases of the life cycle rather than immediately, as JSP technology would do. Additionally, the expressions can be used to set as well as get data, so that the values a user enters into the UI components are propagated to server-side objects during a <CODE>postback</CODE>. Finally, some JavaServer Faces technology expressions can invoke methods on server-side objects during various stages of the life cycle in order to validate data and handle component events. </P>
<P>Each EL suited the needs of its respective technology very well. When using both JSP technology tags or template text and JavaServer Faces technology tags, however, page authors would expose incompatibilities between the ELs. One example involves using JavaServer Faces components inside the <CODE>c:forEach</CODE> tag, as in the following example: </P><!-- BEGIN VCD7 CODE SAMPLE COMPONENT  -->
<TABLE class=grey4 cellSpacing=0 cellPadding=10 width="100%" border=0>
<TBODY>
<TR>
<TD><PRE>    &lt;c:forEach var="location" items="${handler.locations}"&gt;<BR>      &lt;h:inputText value="#{location}"/&gt;<BR>    &lt;/c:forEach&gt;<BR></PRE></TD></TR></TBODY></TABLE><SPAN class=sp20>&nbsp;</SPAN><BR><!-- END VCD7 CODE SAMPLE COMPONENT  -->
<P>The problem with this code stems from the fact that the iteration variable <CODE>location</CODE> is visible only within the boundaries of its iteration tag. This means that on a <CODE>postback</CODE>, the JavaServer Faces request life cycle has no way to access the value associated with the variable <CODE>location</CODE>. </P>
<P>To solve problems such as these, the expert groups for JavaServer Faces and JSP technologies decided to unify the two ELs. They created a more powerful EL, the unified EL, that supports the following features: </P>
<UL>
<LI>Deferred expressions, which can be evaluated at different stages of the page life cycle<BR>
<LI>Expressions that can set data of external objects as well as get that data<BR>
<LI>Method expressions, which can invoke methods that perform event handling, validation, and other functions for the JavaServer Faces technology UI components <BR>
<LI>A flexible mechanism to enable customization of variable and property resolution for EL expression evaluation </LI></UL>
<P>With the addition of these features into a unified EL, the incompatibility problems such as that illustrated by the preceding <CODE>c:forEach</CODE> code example can be solved. Now, the iteration variable can be a deferred expression that refers to the proper object within the collection being iterated over -- for example, <CODE>locations[0]</CODE>. This way, the deferred expression can be evaluated later on during the JavaServer Faces request life cycle, as shown in the following code: </P><!-- BEGIN VCD7 CODE SAMPLE COMPONENT  -->
<TABLE class=grey4 cellSpacing=0 cellPadding=10 width="100%" border=0>
<TBODY>
<TR>
<TD><PRE>  &lt;c:forEach var="location" items=<STRONG>"#{locations}"</STRONG>&gt;<BR>      &lt;h:inputText value="#{location}"/&gt;<BR>    &lt;/c:forEach&gt;<BR></PRE></TD></TR></TBODY></TABLE><SPAN class=sp20>&nbsp;</SPAN><BR><!-- END VCD7 CODE SAMPLE COMPONENT  -->
<P>For more details on changes made to the <CODE>c:forEach</CODE> tag and other JSTL tags, please see the upcoming article of this series, which will describe new features in JSTL. If you are a page author, make sure to read another upcoming article in the series, which describes the differences between the two EL syntaxes now supported in JSP technology. The article "<A href="http://jscpreview.sfbay.sun.com/products/jsp/reference/techart/unifiedEL.html">Unified Expression Language (EL)</A>" provides a much more detailed description. It also explains how to create a custom resolver, which is one of the new features of the unified EL. </P>
<P>It is also important to note that the EL is useful beyond all of the web technology specifications. This is why the EL is agnostic of the technology hosting it and is currently defined through its own independent document within the JSP specification. This makes it clear that the EL is not dependent on the JSP specification and might therefore have its own JSR in the future. </P>
<DIV><B>Resource Injection on the Web Tier</B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>Prior to the Java EE 5 platform, accessing data sources, web services, environment entries, and Enterprise JavaBeans (EJB) bean references required the use of the Java Naming and Directory Interface (JNDI) API along with the declaration of entries into a deployment descriptor. Thanks to injection annotations, it is now possible to inject container-managed objects without having to write the traditional boilerplate code and deal with the deployment descriptor. </P>
<P>For example, a tag handler could access a database through the following code: </P><!-- BEGIN VCD7 CODE SAMPLE COMPONENT  -->
<TABLE class=grey4 cellSpacing=0 cellPadding=10 width="100%" border=0>
<TBODY>
<TR>
<TD><PRE>  @Resource(name="jdbc/myDB") <BR>  javax.sql.DataSource myDB;<BR>  public getProductsByCategory() {<BR>      // Get a connection and execute the query.<BR>      Connection conn = mydb.getConnection();<BR>      ...<BR>  }<BR></PRE></TD></TR></TBODY></TABLE><SPAN class=sp20>&nbsp;</SPAN><BR><!-- END VCD7 CODE SAMPLE COMPONENT  -->
<P>The field <CODE>myDB</CODE> of type <CODE>javax.sql.DataSource</CODE> is annotated with <CODE>@Resource</CODE> and is injected by the container prior to the tag handler being made available to the application. The data source JNDI mapping is inferred from the field name <CODE>catalogDS</CODE> and type <CODE>javax.sql.DataSource</CODE>. Moreover, the <CODE>myDB</CODE> resource no longer needs to be defined in the deployment descriptor. An upcoming article in this series will provide more detail on how to perform injection with web-tier applications. </P>
<DIV><B>Removing Blank Lines: <CODE>TrimWhiteSpace</CODE></B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>A frequent complaint in user forums concerns the large number of blank lines, or white spaces, that often clutter the output of a JSP technology page. For example, consider this page: </P><!-- BEGIN VCD7 CODE SAMPLE COMPONENT  -->
<TABLE class=grey4 cellSpacing=0 cellPadding=10 width="100%" border=0>
<TBODY>
<TR>
<TD><PRE>  &lt;%@page contentType="text/html"%&gt;<BR>  &lt;%@page trimDirectiveWhitespaces="false"%&gt;<BR>  &lt;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt; <BR>  &lt;jsp:useBean id="conference" class="conf.Conference" scope="page" /&gt;<BR><BR>  &lt;%-- <BR>    Test JSP page to showcase the trimWhiteSpace directive.<BR>    A few more lines here to create<BR>    more blank lines in the output.<BR>  --%&gt;<BR>  &lt;html&gt;<BR>    &lt;head&gt;<BR>      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;<BR>      &lt;title&gt;Test trimWhiteSpace directive&lt;/title&gt;<BR>    &lt;/head&gt;<BR>    &lt;body&gt;<BR>      &lt;h1&gt;Test trimWhiteSpace directive&lt;/h1&gt;<BR>  <BR>      Hello Pedro!&lt;br&gt;For the conference, you'll need to bring:&lt;br&gt; <BR>      &lt;c:forEach items="${conference.items}" <BR>		var="conf" varStatus="stat"&gt;<BR>        ${conf} &lt;br&gt;<BR>      &lt;/c:forEach&gt;<BR>    &lt;/body&gt;<BR>  &lt;/html&gt;<BR></PRE></TD></TR></TBODY></TABLE><SPAN class=sp20>&nbsp;</SPAN><BR><!-- END VCD7 CODE SAMPLE COMPONENT  -->
<P>Prior to JSP 2.1 technology, this page would produce the following output in the response (where <CODE>¬</CODE> represents the end of a blank line): </P><!-- BEGIN VCD7 CODE SAMPLE COMPONENT  -->
<TABLE class=grey4 cellSpacing=0 cellPadding=10 width="100%" border=0>
<TBODY>
<TR>
<TD><PRE>  ¬<BR>	¬<BR>	¬<BR>	¬<BR>  &lt;html&gt;<BR>    &lt;head&gt;<BR>      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;<BR>      &lt;title&gt;Test trimWhiteSpace directive&lt;/title&gt;<BR>    &lt;/head&gt;<BR>    &lt;body&gt;<BR>      &lt;h1&gt;Test trimWhiteSpace directive&lt;/h1&gt;<BR>      ¬  <BR>        Hello Pedro!&lt;br&gt;For the conference, you'll need to bring:&lt;br&gt; <BR>      ¬  <BR>        laptop &lt;br&gt; <BR>      ¬  <BR>        white papers &lt;br&gt; <BR>      ¬  <BR>        candy bars &lt;br&gt; <BR>      ¬  <BR>    &lt;/body&gt;<BR>  &lt;/html&gt;<BR></PRE></TD></TR></TBODY></TABLE><SPAN class=sp20>&nbsp;</SPAN><BR><!-- END VCD7 CODE SAMPLE COMPONENT  -->
<P>Although these extra blank lines do not change the way a browser displays the output page, they do add extra payload to the response and make the HTML source code less legible. To solve this issue, JSP 2.1 technology now offers the configuration parameter <CODE>trimDirectiveWhitespaces</CODE>, which can be specified as a page directive or as a property-group configuration parameter that applies to a group of pages. </P>
<P>With <CODE>trimDirectiveWhitespaces</CODE> enabled, template text containing only blank lines, or white space, is removed from the response output. In the code example above, the lines containing only blank lines would be removed, yielding the following output: </P><!-- BEGIN VCD7 CODE SAMPLE COMPONENT  -->
<TABLE class=grey4 cellSpacing=0 cellPadding=10 width="100%" border=0>
<TBODY>
<TR>
<TD><PRE>  &lt;html&gt;<BR>    &lt;head&gt;<BR>      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;<BR>      &lt;title&gt;Test trimWhiteSpace directive&lt;/title&gt;<BR>    &lt;/head&gt;<BR>    &lt;body&gt;<BR>      &lt;h1&gt;Test trimWhiteSpace directive&lt;/h1&gt;<BR><BR>        Hello Pedro!&lt;br&gt;For the conference, you'll need to bring:&lt;br&gt;<BR>      laptop&lt;br&gt;<BR>      white papers&lt;br&gt;<BR>      candy bars&lt;br&gt;<BR>      &lt;/body&gt;<BR>  &lt;/html&gt;<BR></PRE></TD></TR></TBODY></TABLE><SPAN class=sp20>&nbsp;</SPAN><BR><!-- END VCD7 CODE SAMPLE COMPONENT  -->
<DIV><B>Backward Compatibility</B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>Maintaining compatibility with earlier versions is critical for any Java EE platform release. For JSP 2.1 technology, the only backward compatibility issue involves the EL's new support of the <CODE>#{</CODE> syntax that refers to deferred expressions. The <CODE>#{</CODE> character sequence can create backward compatibility problems in two situations: when the sequence is included in template text or in attribute values. </P>
<P>In JSP 2.1 technology, a deferred expression does not make sense in the context of template text because evaluation of an expression is always done immediately by the JSP container. Because no entity other than the JSP container processes template text, a deferred expression would always be left unevaluated if it were included in template text. Therefore, any page authors who have included the <CODE>#{</CODE> character sequence in template text probably meant to use the <CODE>${}</CODE> syntax instead. Acknowledging this fact, the JSP specification authors have mandated that the inclusion of <CODE>#{</CODE> in template text triggers a translation error in JSP 2.1 technology. </P>
<P>With respect to tag attribute values, it is important to note that tag libraries based on JSP versions prior to 2.1 (such as the 1.1 version of the JavaServer Faces component tag library) made extensive use of the <CODE>#{</CODE> syntax to specify deferred expressions. Because these tag libraries must be responsible for the parsing of these deferred expressions, they must execute in an environment in which the <CODE>#{</CODE> character sequence is processed as a string literal. </P>
<P>To determine whether or not to treat the <CODE>#{</CODE> character sequence as a string literal, the web container relies on the JSP version indicated by the tag library descriptor (TLD) associated with the tag library. The JSP version specified in the TLD tells the web container which version of the JSP specification the tag library is written for. JSP versions previous to 2.1 processed <CODE>#{</CODE> as a string literal, as did applications based on those earlier versions. With version 2.1 or later, the character sequence <CODE>#{</CODE> represents a deferred expression, assuming the attribute has been declared to support deferred expressions in the TLD. If the attribute does not support deferred expressions, then the presence of the <CODE>#{</CODE> character sequence results in a translation error. </P>
<P>Web-application developers who have developed applications for a version prior to JSP 2.1 technology and want to deploy and run them on a JSP 2.1 container must take the following actions to ensure that the container handles any instances of the <CODE>#{</CODE> character sequence correctly: </P>
<UL>
<LI>Escape each instance of the <CODE>#{</CODE> characters using a backslash: <CODE>\#{</CODE>.<BR>
<LI>Globally allow usage of the <CODE>#{</CODE> character sequence as a string literal by setting the JSP property groups element <CODE>deferred-syntax-allowed-as-literal</CODE> to <CODE>true</CODE> or by setting the <CODE>page/tag-file</CODE> directive attribute <CODE>deferredSyntaxAllowedAsStringLiteral</CODE> to <CODE>true</CODE>. </LI></UL>
<P>Aside from the incompatibilities relating to the <CODE>#{</CODE> character sequence, all JSP 2.0 technology applications will run as is on JSP 2.1 containers. However, if a web application uses third-party tag libraries that are based on JavaServer Faces 1.1 technology or earlier, some new features provided by JSP 2.1 and JavaServer Faces 1.2 technologies will not be available with these libraries. For example, although EL functions may now be used in the JavaServer Faces 1.2 core and HTML tag libraries, they cannot be used with third-party tag libraries that are based on JavaServer Faces 1.1 technology and earlier, because these libraries run on a version of the JavaServer Faces EL that did not support EL functions. </P>
<DIV><B><CODE>Taglib</CODE> Order of Precedence</B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>Now that JavaServer Faces technology and JSTL are part of the Java EE 5 platform, they take precedence over any other version of these libraries that could be bundled with a web application. Some people may ask: "But what if I want to replace the container's implementation of these technologies with another implementation?" This is no longer possible. This would be like replacing the implementation of the <CODE>java.util package</CODE> in the Java Platform, Standard Edition (Java SE, formerly referred to as J2SE), a fruitless task. The same applies from now on with platform tag libraries. </P>
<P>Essentially, applications should not replace the APIs that the Java EE 5 platform requires. If the platform architects really wanted to make this possible, they would have designed the APIs with service-provider interfaces to allow applications to easily swap in their own implementations. However, this was not their intention, and applications will always have to rely on the platform tag libraries bundled with a container. </P>
<DIV><B>Other Additions and Clarifications</B></DIV>
<DIV class=contentdivider>
<TABLE class=grey4 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=4 alt=" " src="http://java.sun.com/im/a.gif" width=1 border=0></TD></TR></TBODY></TABLE></DIV>
<P>Let's look at a few other minor additions and clarifications to the JSP 2.1 specification. For a detailed list of all changes between JSP 2.0 and JSP 2.1, please consult Appendix E of the specification. Most notable are the following: </P>
<UL>
<LI>The JSP spec now supports Byte Order Marks (BOM) as authoritative page-encoding declarations for JSP technology pages and tag files in standard syntax.<BR>
<LI>Because JSP 2.1 technology requires J2SE 5.0, some APIs that can take advantage of generics have been modified.<BR>
<LI>And many more, as Appendix E points out. </LI></UL><img src ="http://www.blogjava.net/guming123416/aggbug/31920.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-02-22 10:32 <a href="http://www.blogjava.net/guming123416/archive/2006/02/22/31920.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IIS6.0与Resin_3.0.8的整合</title><link>http://www.blogjava.net/guming123416/archive/2006/02/22/31913.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Wed, 22 Feb 2006 02:22:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/02/22/31913.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/31913.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/02/22/31913.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/31913.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/31913.html</trackback:ping><description><![CDATA[&nbsp;&nbsp; <FONT size=2>经过两天的尝试，今天终于将整合了IIS6.0和Resin_3.0.8。下面我把这两天的心得写出来与大家交流一下。<BR>&nbsp;&nbsp;&nbsp; 在此之前，我想从网上找些资料。不过，关于IIS与Resin整合的文章很少，而有关IIS6.0整合的文章就更少了。到Resin的官方网站上，虽然是有关IIS与Resin整合的文章。不过是英文，而且版本很低，是Resin_2.1的。最后只有一点一点的摸索。后来又看到了Resin_3.0.8里面自带的文档中有一部分是关于IIS6.0与Resin_3.0.8整合的内容。按照上面说的，终于将IIS6.0与Resin_3.0.8整合好了。Resin的官方文挡写的不是很清楚。特别有些地方很中文版的IIS6.0有些出入。<BR>&nbsp;&nbsp;&nbsp; 1、安装好J2SDK和Resin.（我J2SDK是安装在D:\J2SDK下的，Resin是解压缩在D:\Resin_3.0.8文件夹下的）。<BR>&nbsp;&nbsp;&nbsp; 2、环境变量。在我的电脑上单击鼠标右键→属性→高级→环境变量。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1）新建两个系统变量（单击下面的新建）：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ①变量名：JAVA_HOME<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 变量值：D:\J2SDK（J2SDK安装的目录）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ②变量名：classpath<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 变量值：.;%JAVA_HOME%\lib\tools.jar（注：前面是一个小数点加个分<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 号，直接复制就可以）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ③变量名：RESIN_HOME<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 变量值：D:\Resin_3.0.8（Resin安装的目录）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2）编辑系统变量Path<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在变量值后面追加;%JAVA_HOME%\bin\<BR>&nbsp;&nbsp;&nbsp; 3、复制文件。在windows2003下面是不能使用Rensin_3.0.8\bin\setup.exe。运行setup回报错。这就需要我们自己来复制文件。我的IIS是安装在C:\Inetpub下的。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1）C:\Inetpub下面新建一个文件夹，重命名为scripts<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2）把Rensin_3.0.8\libexec下的isapi_srun.dll复制到<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C:\Inetpub\scripts下<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3）在C:\Inetpub\scripts新建一个resin.ini文件。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文件内容下面两行数据：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ResinConfigServer localhost 6802<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IISPriority high<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; （官方的文档上说只有需要建立多个站点的时候才必须使用<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resin.ini。如果只有一个站点就没必要新建resin.ini。推荐使用）<BR>&nbsp;&nbsp;&nbsp; 4、设置IIS。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1）在默认网站上单击右键→属性→ISAPI筛选器→添加<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 筛选器名称：Resin_3.0.8（可随便填）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 可执行文件：C:\Inetpub\scripts\isapi_srun.dll<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2）在默认网站上单击右键→新建→虚拟目录<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 别名：scripts<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本地路径：C:\Inetpub\scripts<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3）单击WEB服务扩展→添加一个新的WEB服务扩展<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 扩展名：Resin（可随便添）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 要求文件：C:\Inetpub\scripts\isapi_srun.dll<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 选中设置扩展状态为允许<BR>&nbsp;&nbsp;&nbsp; 5、设置Resin_3.0.8\conf\resin.conf。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在文件中找到（大概是在最后）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;host id=''&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;document-directory&gt;doc&lt;/document-directory&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 改成<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;host id=''&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;document-directory&gt;c:/inetpub/wwwroot&lt;/document-directory&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; （c:/inetpub/wwwroot，为你的默认网站的目录）<BR>&nbsp;&nbsp;&nbsp; 好，到这里，我们就完全设置完了。<BR>&nbsp;&nbsp;&nbsp; 然后先运行net stop w3svc关闭IIS服务。<BR>&nbsp;&nbsp;&nbsp; 再运行net start w3svc重新启动IIS。<BR>&nbsp;&nbsp;&nbsp; 打开Resin_3.0.8\bin\httpd.exe。<BR>&nbsp;&nbsp;&nbsp; 现在IIS6.0与Resin_3.0.8已经成功整合了。我们可以将httpd.exe作为服务启动。那么，计算机启动的时候就会启动httpd.exe。<BR>&nbsp;&nbsp;&nbsp; 安装服务<BR>&nbsp;&nbsp;&nbsp; d:\resin_3.0.8\bin\httpd.exe -install<BR>&nbsp;&nbsp;&nbsp; 取消服务<BR>&nbsp;&nbsp;&nbsp; d:\resin_3.0.8\bin\httpd.exe -remove</FONT> 
<P><FONT size=2>&nbsp;&nbsp;&nbsp; IIS6.0与Resin_3.0.8的整合困扰了我好几天。现在写出来跟大家交流一下。有什么错误请大家指出来。</FONT></P><img src ="http://www.blogjava.net/guming123416/aggbug/31913.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-02-22 10:22 <a href="http://www.blogjava.net/guming123416/archive/2006/02/22/31913.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>优化JDBC性能的三大技巧</title><link>http://www.blogjava.net/guming123416/archive/2006/02/22/31912.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Wed, 22 Feb 2006 02:21:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/02/22/31912.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/31912.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/02/22/31912.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/31912.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/31912.html</trackback:ping><description><![CDATA[<SPAN id=LblContent>开发一个注重性能的JDBC应用程序不是一件容易的事. 当你的代码运行很慢的时候JDBC驱动程序并不会抛出异常告诉你。<BR><BR>　　本系列的性能提示将为改善JDBC应用程序的性能介绍一些基本的指导原则，这其中的原则已经被许多现有的JDBC应用程序编译运行并验证过。 这些指导原则包括:<BR>　正确的使用数据库MetaData方法 <BR>　　　只获取需要的数据 <BR>　　　选用最佳性能的功能 <BR>　　　管理连接和更新 <BR><BR>　　以下这些一般性原则可以帮助你解决一些公共的JDBC系统的性能问题.<BR><BR>　　<STRONG><FONT color=#990000>使用数据库Metadata方法</FONT></STRONG><BR><BR>　　因为通过ResultSet对象生成的Metadata方法与其它的JDBCB方法相比是较慢的, 经常的使用它们将会削弱系统的的性能. 本节的指导原则将帮助你选择和使用meatdata时优化系统性能.<BR><BR>　　<STRONG>少用Metadata方法</STRONG> <BR><BR>　　与其它的JDBC方法相比, 由ResultSet对象生成的metadata对象的相对来说是很慢的. 应用程序应该缓存从ResultSet返回的metadata信息，避免多次不必要的执行这个操作.<BR><BR>　　几乎没有哪一个JDBC应用程序不用到metadata，虽然如此，你仍可以通过少用它们来改善系统性能. 要返回JDBC规范规定的结果集的所有列信息, 一个简单的metadata的方法调用可能会使JDBC驱动程序去执行很复杂的查询甚至多次查询去取得这些数据. 这些细节上的SQL语言的操作是非常消耗性能的. <BR><BR>　　应用程序应该缓存这些metadata信息. 例如, 程序调用一次getTypeInfo方法后就将这些程序所依赖的结果信息缓存. 而任何程序都不大可能用到这些结果信息中的所有内容，所以这些缓存信息应该是不难维护的.<BR><BR>　　<STRONG>避免null参数</STRONG><BR><BR>　　在metadata的方法中使用null参数或search patterns是很耗时的. 另外, 额外的查询会导致潜在的网络交通的增加. 应尽可能的提供一些non-null的参数给metadata方法.<BR><BR>　　因为metadata的方法很慢, 应用程序要尽可能有效的调用它们. 许多应用程序只传递少量的non-null参数给这些方法.<BR><BR>　　例如:<BR><BR>ResultSet WSrs = WSc.getTables (null, null, "WSTable", null); <BR><BR>　　应该这样:<BR><BR>ResultSet WSrs = WSc.getTables ("cat1", "johng", "WSTable", "TABLE"); <BR><BR>　　在第一个getTables()的调用中, 程序可能想知道表'WSTable'是否存在. 当然, JDBC驱动程序会逐个调用它们并且会解译不同的请求. JDBC驱动程序会解译请求为: 返回所有的表, 视图, 系统表, synonyms, 临时表, 或存在于任何数据库类别任何Schema中的任何别名为'WSTable'的对象.<BR><BR>　　第二个getTables()的调用会得到更正确的程序想知道的内容. JDBC驱动程序会解译这个请求为: 返回当前数据库类别中所有存在于'johng'这个schema中的所有表. <BR><BR>　　很显然, JDBC驱动程序处理第二个请求比处理第一个请求更有效率一些.<BR><BR>　　有时, 你所请求信息中的对象有些信息是已知的. 当调用metadata方法时, 程序能传送到驱动程序的的任何有用信息都可以导致性能和可靠性的改善. <BR><BR>　　<STRONG>使用'哑元'(dummy)查询确定表的特性</STRONG><BR><BR>　　要避免使用getColumns()去确定一个表的特性. 而应该使用一个‘哑元’查询来使用getMetadata()方法.<BR><BR>　　请考虑这样一个程序, 程序中要允许用户选取一些列. 我们是否应该使用getColumns()去返回列信息给用户还是以一个'哑元'查询来调用getMetadata()方法呢?<BR><BR>　　案例 1: GetColumns 方法<BR><BR>
<TABLE width="90%" bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD>ResultSet WSrc = WSc.getColumns (... "UnknownTable" ...);<BR>// getColumns()会发出一个查询给数据库系统<BR>. . .<BR>WSrc.next();<BR>string Cname = getString(4);<BR>. . .<BR>// 用户必须从反复从服务器获取N行数据<BR>// N = UnknownTable的列数</TD></TR></TBODY></TABLE><BR>　　案例 2: GetMetadata 方法<BR><BR>
<TABLE width="90%" bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD>// 准备'哑元'查询<BR>PreparedStatement WSps = WSc.prepareStatement<BR>("SELECT * from UnknownTable WHERE 1 = 0");<BR>// 查询从来没有被执行，只是被预储<BR>ResultSetMetaData WSsmd=WSps.getMetaData();<BR>int numcols = WSrsmd.getColumnCount();<BR>...<BR>int ctype = WSrsmd.getColumnType(n)<BR>...<BR>// 获得了列的完整信息 </TD></TR></TBODY></TABLE><BR>　　在这两个案例中, 一个查询被传送到服务器. 但在案例1中, 查询必须被预储和执行, 结果的描述信息必须确定(以传给getColumns()方法), 并且客户端必须接收一个包含列信息的结果集. 在案例2中, 只要准备一个简单的查询并且只用确定结果描述信息. 很显然, 案例2执行方式更好一些. <BR><BR>　　这个讨论有点复杂, 让我们考虑一个没有本地化支持prepared statement的DBMS服务器. 案例1的性能没有改变, 但案例2中, 因为'哑元'查询必须被执行而不是被预储使得它的性能增强了一些. 因为查询中的WHERE子句总是为FALSE, 查询在不用存取表的数据情况的下会生成没有数据的结果集. 在这种情况下，第二种方式当然比第一种方式好一些.<BR><BR>　　总而言之，总是使用ResultSet的metadata方法去获取列信息，像列名,列的数据类型,列的数据精度和长度等. 当要求的信息无法从ResultSet的metadata中获取时才去用getColumns()方法(像列的缺省值这些信息等)。<BR></SPAN><img src ="http://www.blogjava.net/guming123416/aggbug/31912.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-02-22 10:21 <a href="http://www.blogjava.net/guming123416/archive/2006/02/22/31912.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用实例说明如何用JavaScript生成XML </title><link>http://www.blogjava.net/guming123416/archive/2006/01/23/29006.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Mon, 23 Jan 2006 05:34:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/01/23/29006.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/29006.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/01/23/29006.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/29006.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/29006.html</trackback:ping><description><![CDATA[<FONT color=#993300 size=2>&lt;script language="javascript"&gt; <BR>&lt;!-- <BR>var doc = new ActiveXObject("Msxml2.DOMDocument"); //ie5.5+,CreateObject("Microsoft.XMLDOM")&nbsp; <BR><BR><BR>//加载文档 <BR>//doc.load("b.xml"); <BR><BR>//创建文件头 <BR>var p = doc.createProcessingInstruction<BR>("xml","version=’’1.0’’&nbsp; <BR>encoding=’’gb2312’’"); <BR><BR>&nbsp;&nbsp;&nbsp; //添加文件头 <BR>&nbsp;&nbsp;&nbsp; doc.appendChild(p); <BR><BR>//用于直接加载时获得根接点 <BR>//var root = doc.documentElement; <BR><BR>//两种方式创建根接点 <BR>//&nbsp;&nbsp;&nbsp; var root = <BR>doc.createElement("students"); <BR>&nbsp;&nbsp;&nbsp; var root = doc.createNode(1,"students",""); <BR><BR>&nbsp;&nbsp;&nbsp; //创建子接点 <BR>&nbsp;&nbsp;&nbsp; var n = doc.createNode(1,"ttyp",""); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //指定子接点文本 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //n.text = " this is a test"; <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; //创建孙接点 <BR>&nbsp;&nbsp;&nbsp; var o = doc.createElement("sex"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.text = "男";&nbsp;&nbsp;&nbsp; <BR>//指定其文本 <BR><BR>&nbsp;&nbsp;&nbsp; //创建属性 <BR>&nbsp;&nbsp;&nbsp; var r = doc.createAttribute("id"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r.value="test"; <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加属性 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n.setAttributeNode(r); <BR><BR>&nbsp;&nbsp;&nbsp; //创建第二个属性&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; var r1 = doc.createAttribute("class"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r1.value="tt"; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加属性 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n.setAttributeNode(r1); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //删除第二个属性 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n.removeAttribute("class"); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加孙接点 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n.appendChild(o); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加文本接点 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n.appendChild(doc.createTextNode<BR>("this is a text node.")); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加注释 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n.appendChild(doc.createComment<BR>("this is a comment\n")); <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加子接点 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root.appendChild(n); <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; //复制接点 <BR>&nbsp;&nbsp;&nbsp; var m = n.cloneNode(true); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root.appendChild(m); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //删除接点 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root.removeChild(root.childNodes(0)); <BR><BR>&nbsp;&nbsp;&nbsp; //创建数据段 <BR>&nbsp;&nbsp;&nbsp; var c = doc.createCDATASection<BR>("this is a cdata"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c.text = "hi,cdata"; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //添加数据段 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root.appendChild(c); <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; //添加根接点 <BR>&nbsp;&nbsp;&nbsp; doc.appendChild(root); <BR><BR>&nbsp;&nbsp;&nbsp; //查找接点 <BR>&nbsp;&nbsp;&nbsp; var a = doc.getElementsByTagName("ttyp"); <BR>&nbsp;&nbsp;&nbsp; //var a = doc.selectNodes("//ttyp"); <BR><BR>&nbsp;&nbsp;&nbsp; //显示改接点的属性 <BR>&nbsp;&nbsp;&nbsp; for(var i= 0;i&lt;a.length;i++) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(a[i].xml); <BR>for(var j=0;j&lt;a[i].attributes.length;j++) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(a[i].attributes[j].name); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; } <BR><BR>&nbsp;&nbsp;&nbsp; //XML保存（需要在服务端，客户端用FSO） <BR>&nbsp;&nbsp;&nbsp; //doc.save(); <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; //查看根接点XML <BR>&nbsp;&nbsp;&nbsp; if(n) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(n.ownerDocument.xml); <BR>&nbsp;&nbsp;&nbsp; } <BR><BR>//--&gt; <BR>&lt;/script&gt;</FONT><BR><img src ="http://www.blogjava.net/guming123416/aggbug/29006.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-01-23 13:34 <a href="http://www.blogjava.net/guming123416/archive/2006/01/23/29006.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>正则表达式系统教程-----------(转) </title><link>http://www.blogjava.net/guming123416/archive/2006/01/23/29002.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Mon, 23 Jan 2006 05:11:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/01/23/29002.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/29002.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/01/23/29002.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/29002.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/29002.html</trackback:ping><description><![CDATA[近来学习正则表达式，看到这篇文章，很不错。<BR><BR><STRONG>前言<BR><BR></STRONG>　　正则表达式是烦琐的，但是强大的，学会之后的应用会让你除了提高效率外，会给你带来绝对的成就感。只要认真去阅读这些资料，加上应用的时候进行一定的参考，掌握正则表达式不是问题。<BR><BR><STRONG>索引</STRONG><BR><BR><STRONG>1. 引子<BR></STRONG>　　目前，正则表达式已经在很多软件中得到广泛的应用，包括*nix（Linux, Unix等），HP等操作系统，PHP，C#，Java等开发环境，以及很多的应用软件中，都可以看到正则表达式的影子。<BR><BR>　　正则表达式的使用，可以通过简单的办法来实现强大的功能。为了简单有效而又不失强大，造成了正则表达式代码的难度较大，学习起来也不是很容易，所以需要付出一些努力才行，入门之后参照一定的参考，使用起来还是比较简单有效的。<BR><BR>　　例子： ^.+@.+\\..+$ <BR><BR>　　这样的代码曾经多次把我自己给吓退过。可能很多人也是被这样的代码给吓跑的吧。继续阅读本文将让你也可以自由应用这样的代码。<BR><BR>　　注意：这里的第7部分跟前面的内容看起来似乎有些重复，目的是把前面表格里的部分重新描述了一次，目的是让这些内容更容易理解。<BR><STRONG>2. 正则表达式的历史<BR><BR></STRONG>　　正则表达式的“祖先”可以一直上溯至对人类神经系统如何工作的早期研究。Warren McCulloch 和 Walter Pitts 这两位神经生理学家研究出一种数学方式来描述这些神经网络。<BR><BR>　 　1956 年, 一位叫 Stephen Kleene 的数学家在 McCulloch 和 Pitts 早期工作的基础上，发表了一篇标题为“神经网事件的表示法”的论文，引入了正则表达式的概念。正则表达式就是用来描述他称为“正则集的代数”的表达式，因 此采用“正则表达式”这个术语。<BR><BR>　　随后，发现可以将这一工作应用于使用 Ken Thompson 的计算搜索算法的一些早期研究，Ken Thompson 是 Unix 的主要发明人。正则表达式的第一个实用应用程序就是 Unix 中的 qed 编辑器。<BR><BR>　　如他们所说，剩下的就是众所周知的历史了。从那时起直至现在正则表达式都是基于文本的编辑器和搜索工具中的一个重要部分。<BR><STRONG>3. 正则表达式定义<BR><BR></STRONG>　　正则表达式(regular expression)描述了一种字符串匹配的模式，可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。<BR><BR>　　列目录时，　dir *.txt或ls *.txt中的*.txt就不是一个正则表达式,因为这里*与正则式的*的含义是不同的。 <BR><BR>　　正则表达式是由普通字符（例如字符 a 到 z）以及特殊字符（称为元字符）组成的文字模式。正则表达式作为一个模板，将某个字符模式与所搜索的字符串进行匹配。<BR><A name=31></A><BR>　　3.1 普通字符<BR><BR>　　由所有那些未显式指定为元字符的打印和非打印字符组成。这包括所有的大写和小写字母字符，所有数字，所有标点符号以及一些符号。 <BR><A name=32></A><BR>　　3.2 非打印字符<BR><BR>
<TABLE cellSpacing=1 cellPadding=3 align=center bgColor=#eaeaea border=0>
<TBODY>
<TR bgColor=#f0f0f0>
<TH style="FONT-SIZE: 12px" align=left>字符 </TH>
<TH style="FONT-SIZE: 12px" align=left>含义</TH></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px" width=40>\cx </TD>
<TD style="FONT-SIZE: 12px">匹配由x指明的控制字符。例如， \cM 匹配一个 Control-M 或回车符。x 的值必须为 A-Z 或 a-z 之一。否则，将 c 视为一个原义的 'c' 字符。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\f </TD>
<TD style="FONT-SIZE: 12px">匹配一个换页符。等价于 \x0c 和 \cL。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\n </TD>
<TD style="FONT-SIZE: 12px">匹配一个换行符。等价于 \x0a 和 \cJ。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\r </TD>
<TD style="FONT-SIZE: 12px">匹配一个回车符。等价于 \x0d 和 \cM。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\s </TD>
<TD style="FONT-SIZE: 12px">匹配任何空白字符，包括空格、制表符、换页符等等。等价于 [ \f\n\r\t\v]。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\S </TD>
<TD style="FONT-SIZE: 12px">匹配任何非空白字符。等价于 [^ \f\n\r\t\v]。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\t </TD>
<TD style="FONT-SIZE: 12px">匹配一个制表符。等价于 \x09 和 \cI。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\v </TD>
<TD style="FONT-SIZE: 12px">匹配一个垂直制表符。等价于 \x0b 和 \cK。</TD></TR></TBODY></TABLE><BR><A name=33></A>　<BR>　　3.3 特殊字符<BR><BR>　　所谓特殊字符，就是一些有特殊含义的字符，如上面说的"*.txt"中的*，简单的说就是表示任何字符串的意思。如果要查找文件名中有＊的文件，则需要对＊进行转义，即在其前加一个\。ls \*.txt。正则表达式有以下特殊字符。<BR><BR>
<TABLE cellSpacing=1 cellPadding=3 align=center bgColor=#eaeaea border=0>
<TBODY>
<TR bgColor=#f0f0f0>
<TH style="FONT-SIZE: 12px" align=left width=60>特别字符</TH>
<TH style="FONT-SIZE: 12px" align=left>说明</TH></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">$</TD>
<TD style="FONT-SIZE: 12px">匹配输入字符串的结尾位置。如果设置了 RegExp 对象的 Multiline 属性，则 $ 也匹配 '\n' 或 '\r'。要匹配 $ 字符本身，请使用 \$。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">( )</TD>
<TD style="FONT-SIZE: 12px">标记一个子表达式的开始和结束位置。子表达式可以获取供以后使用。要匹配这些字符，请使用 \( 和 \)。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">*</TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式零次或多次。要匹配 * 字符，请使用 \*。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">+</TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式一次或多次。要匹配 + 字符，请使用 \+。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">.</TD>
<TD style="FONT-SIZE: 12px">匹配除换行符 \n之外的任何单字符。要匹配 .，请使用 \。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">[ </TD>
<TD style="FONT-SIZE: 12px">标记一个中括号表达式的开始。要匹配 [，请使用 \[。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">?</TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式零次或一次，或指明一个非贪婪限定符。要匹配 ? 字符，请使用 \?。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\</TD>
<TD style="FONT-SIZE: 12px">将下一个字符标记为或特殊字符、或原义字符、或向后引用、或八进制转义符。例如， 'n' 匹配字符 'n'。'\n' 匹配换行符。序列 '\\' 匹配 "\"，而 '\(' 则匹配 "("。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">^</TD>
<TD style="FONT-SIZE: 12px">匹配输入字符串的开始位置，除非在方括号表达式中使用，此时它表示不接受该字符集合。要匹配 ^ 字符本身，请使用 \^。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{</TD>
<TD style="FONT-SIZE: 12px">标记限定符表达式的开始。要匹配 {，请使用 \{。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">|</TD>
<TD style="FONT-SIZE: 12px">指明两项之间的一个选择。要匹配 |，请使用 \|。</TD></TR></TBODY></TABLE><BR><BR>　　构造正则表达式的方法和创建数学表达式的方法一样。也就是用多种元字符与操作符将小的表达式结合在一起来创建更大的表达式。正则表达式的组件可以是单个的字符、字符集合、字符范围、字符间的选择或者所有这些组件的任意组合。 <BR>　<BR><A name=34></A><BR>　　3.4 限定符<BR><BR>　　限定符用来指定正则表达式的一个给定组件必须要出现多少次才能满足匹配。有*或+或?或{n}或{n,}或{n,m}共6种。<BR><BR>　　*、+和?限定符都是贪婪的，因为它们会尽可能多的匹配文字，只有在它们的后面加上一个?就可以实现非贪婪或最小匹配。<BR><BR>　　正则表达式的限定符有：<BR><BR>
<TABLE cellSpacing=1 cellPadding=3 align=center bgColor=#eaeaea border=0>
<TBODY>
<TR bgColor=#f0f0f0>
<TH style="FONT-SIZE: 12px" align=left width=40>字符 </TH>
<TH style="FONT-SIZE: 12px" align=left>描述</TH></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">* </TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式零次或多次。例如，zo* 能匹配 "z" 以及 "zoo"。* 等价于{0,}。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">+ </TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式一次或多次。例如，'zo+' 能匹配 "zo" 以及 "zoo"，但不能匹配 "z"。+ 等价于 {1,}。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">? </TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式零次或一次。例如，"do(es)?" 可以匹配 "do" 或 "does" 中的"do" 。? 等价于 {0,1}。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{n} </TD>
<TD style="FONT-SIZE: 12px">n 是一个非负整数。匹配确定的 n 次。例如，'o{2}' 不能匹配 "Bob" 中的 'o'，但是能匹配 "food" 中的两个 o。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{n,} </TD>
<TD style="FONT-SIZE: 12px">n 是一个非负整数。至少匹配n 次。例如，'o{2,}' 不能匹配 "Bob" 中的 'o'，但能匹配 "foooood" 中的所有 o。'o{1,}' 等价于 'o+'。'o{0,}' 则等价于 'o*'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{n,m} </TD>
<TD style="FONT-SIZE: 12px">m 和 n 均为非负整数，其中n &lt;= m。最少匹配 n 次且最多匹配 m 次。例如，"o{1,3}" 将匹配 "fooooood" 中的前三个 o。'o{0,1}' 等价于 'o?'。请注意在逗号和两个数之间不能有空格。</TD></TR></TBODY></TABLE><BR><A name=35></A><BR>　　<STRONG>3.5 定位符</STRONG><BR><BR>　　用来描述字符串或单词的边界，^和$分别指字符串的开始与结束，\b描述单词的前或后边界，\B表示非单词边界。<SPAN style="COLOR: rgb(255,0,0)">不能对定位符使用限定符。 </SPAN><BR><A name=36></A><BR>　　3.6 选择<BR><BR>　　用圆括号将所有选择项括起来，相邻的选择项之间用|分隔。但用圆括号会有一个副作用，是相关的匹配会被缓存，此时可用?:放在第一个选项前来消除这种副作用。<BR><BR>　　其中?:是非捕获元之一，还有两个非捕获元是?=和?!，这两个还有更多的含义，前者为正向预查，在任何开始匹配圆括号内的正则表达式模式的位置来匹配搜索字符串，后者为负向预查，在任何开始不匹配该正则表达式模式的位置来匹配搜索字符串。 <BR><A name=37></A><BR>　　3.7 后向引用<BR><BR>　 　对一个正则表达式模式或部分模式两边添加圆括号将导致相关匹配存储到一个临时缓冲区中，所捕获的每个子匹配都按照在正则表达式模式中从左至右所遇到的内 容存储。存储子匹配的缓冲区编号从 1 开始，连续编号直至最大 99 个子表达式。每个缓冲区都可以使用 '\n' 访问，其中 n 为一个标识特定缓冲区的一位或两位十进制数。<BR><BR>　　可以使用非捕获元字符 '?:', '?=', or '?!' 来忽略对相关匹配的保存。 <BR><STRONG>4. 各种操作符的运算优先级<BR><BR></STRONG>　　相同优先级的从左到右进行运算，不同优先级的运算先高后低。各种操作符的优先级从高到低如下：<BR><BR>
<TABLE cellSpacing=1 cellPadding=3 align=center bgColor=#eaeaea border=0>
<TBODY>
<TR bgColor=#f0f0f0>
<TH style="FONT-SIZE: 12px" align=left width=200 bgColor=#f0f0f0>操作符 </TH>
<TH style="FONT-SIZE: 12px" align=left>描述</TH></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\ </TD>
<TD style="FONT-SIZE: 12px">转义符</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">(), (?:), (?=), [] </TD>
<TD style="FONT-SIZE: 12px">圆括号和方括号</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">*, +, ?, {n}, {n,}, {n,m} </TD>
<TD style="FONT-SIZE: 12px">限定符</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">^, $, \anymetacharacter </TD>
<TD style="FONT-SIZE: 12px">位置和顺序</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">| </TD>
<TD style="FONT-SIZE: 12px">“或”操作</TD></TR></TBODY></TABLE><STRONG>5. 全部符号解释<BR><BR></STRONG>
<TABLE cellSpacing=1 cellPadding=3 align=center bgColor=#eaeaea border=0>
<TBODY>
<TR bgColor=#f0f0f0>
<TH style="FONT-SIZE: 12px" align=left width=80 bgColor=#f0f0f0>字符 </TH>
<TH style="FONT-SIZE: 12px" align=left>描述</TH></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\ </TD>
<TD style="FONT-SIZE: 12px">将下一个字符标记为一个特殊字符、或一个原义字符、或一个 向后引用、或一个八进制转义符。例如，'n' 匹配字符 "n"。'\n' 匹配一个换行符。序列 '\\' 匹配 "\" 而 "\(" 则匹配 "("。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">^ </TD>
<TD style="FONT-SIZE: 12px">匹配输入字符串的开始位置。如果设置了 RegExp 对象的 Multiline 属性，^ 也匹配 '\n' 或 '\r' 之后的位置。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">$ </TD>
<TD style="FONT-SIZE: 12px">匹配输入字符串的结束位置。如果设置了RegExp 对象的 Multiline 属性，$ 也匹配 '\n' 或 '\r' 之前的位置。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">* </TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式零次或多次。例如，zo* 能匹配 "z" 以及 "zoo"。* 等价于{0,}。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">+ </TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式一次或多次。例如，'zo+' 能匹配 "zo" 以及 "zoo"，但不能匹配 "z"。+ 等价于 {1,}。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">? </TD>
<TD style="FONT-SIZE: 12px">匹配前面的子表达式零次或一次。例如，"do(es)?" 可以匹配 "do" 或 "does" 中的"do" 。? 等价于 {0,1}。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{n} </TD>
<TD style="FONT-SIZE: 12px">n 是一个非负整数。匹配确定的 n 次。例如，'o{2}' 不能匹配 "Bob" 中的 'o'，但是能匹配 "food" 中的两个 o。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{n,} </TD>
<TD style="FONT-SIZE: 12px">n 是一个非负整数。至少匹配n 次。例如，'o{2,}' 不能匹配 "Bob" 中的 'o'，但能匹配 "foooood" 中的所有 o。'o{1,}' 等价于 'o+'。'o{0,}' 则等价于 'o*'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">{n,m} </TD>
<TD style="FONT-SIZE: 12px">m 和 n 均为非负整数，其中n &lt;= m。最少匹配 n 次且最多匹配 m 次。例如，"o{1,3}" 将匹配 "fooooood" 中的前三个 o。'o{0,1}' 等价于 'o?'。请注意在逗号和两个数之间不能有空格。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">? </TD>
<TD style="FONT-SIZE: 12px">当该字符紧跟在任何一个其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面时，匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串，而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如，对于字符串 "oooo"，'o+?' 将匹配单个 "o"，而 'o+' 将匹配所有 'o'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">. </TD>
<TD style="FONT-SIZE: 12px">匹配除 "\n" 之外的任何单个字符。要匹配包括 '\n' 在内的任何字符，请使用象 '[.\n]' 的模式。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">(pattern) </TD>
<TD style="FONT-SIZE: 12px">匹配 pattern 并获取这一匹配。所获取的匹配可以从产生的 Matches 集合得到，在VBScript 中使用 SubMatches 集合，在JScript 中则使用 $0…$9 属性。要匹配圆括号字符，请使用 '\(' 或 '\)'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">(?:pattern) </TD>
<TD style="FONT-SIZE: 12px">匹配 pattern 但不获取匹配结果，也就是说这是一个非获取匹配，不进行存储供以后使用。这在使用 "或" 字符 (|) 来组合一个模式的各个部分是很有用。例如， 'industr(?:y|ies) 就是一个比 'industry|industries' 更简略的表达式。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">(?=pattern) </TD>
<TD style="FONT-SIZE: 12px">正向预查，在任何匹配 pattern 的字符串开始处匹配查找字符串。这是一个非获取匹配，也就是说，该匹配不需要获取供以后使用。例如，'Windows (?=95|98|NT|2000)' 能匹配 "Windows 2000" 中的 "Windows" ，但不能匹配 "Windows 3.1" 中的 "Windows"。预查不消耗字符，也就是说，在一个匹配发生后，在最后一次匹配之后立即开始下一次匹配的搜索，而不是从包含预查的字符之后开始。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">(?!pattern) </TD>
<TD style="FONT-SIZE: 12px">负向预查，在任何不匹配 pattern 的字符串开始处匹配查找字符串。这是一个非获取匹配，也就是说，该匹配不需要获取供以后使用。例如'Windows (?!95|98|NT|2000)' 能匹配 "Windows 3.1" 中的 "Windows"，但不能匹配 "Windows 2000" 中的 "Windows"。预查不消耗字符，也就是说，在一个匹配发生后，在最后一次匹配之后立即开始下一次匹配的搜索，而不是从包含预查的字符之后开始</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">x|y </TD>
<TD style="FONT-SIZE: 12px">匹配 x 或 y。例如，'z|food' 能匹配 "z" 或 "food"。'(z|f)ood' 则匹配 "zood" 或 "food"。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">[xyz] </TD>
<TD style="FONT-SIZE: 12px">字符集合。匹配所包含的任意一个字符。例如， '[abc]' 可以匹配 "plain" 中的 'a'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">[^xyz] </TD>
<TD style="FONT-SIZE: 12px">负值字符集合。匹配未包含的任意字符。例如， '[^abc]' 可以匹配 "plain" 中的'p'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">[a-z] </TD>
<TD style="FONT-SIZE: 12px">字符范围。匹配指定范围内的任意字符。例如，'[a-z]' 可以匹配 'a' 到 'z' 范围内的任意小写字母字符。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">[^a-z] </TD>
<TD style="FONT-SIZE: 12px">负值字符范围。匹配任何不在指定范围内的任意字符。例如，'[^a-z]' 可以匹配任何不在 'a' 到 'z' 范围内的任意字符。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\b </TD>
<TD style="FONT-SIZE: 12px">匹配一个单词边界，也就是指单词和空格间的位置。例如， 'er\b' 可以匹配"never" 中的 'er'，但不能匹配 "verb" 中的 'er'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\B </TD>
<TD style="FONT-SIZE: 12px">匹配非单词边界。'er\B' 能匹配 "verb" 中的 'er'，但不能匹配 "never" 中的 'er'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\cx </TD>
<TD style="FONT-SIZE: 12px">匹配由 x 指明的控制字符。例如， \cM 匹配一个 Control-M 或回车符。x 的值必须为 A-Z 或 a-z 之一。否则，将 c 视为一个原义的 'c' 字符。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\d </TD>
<TD style="FONT-SIZE: 12px">匹配一个数字字符。等价于 [0-9]。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\D </TD>
<TD style="FONT-SIZE: 12px">匹配一个非数字字符。等价于 [^0-9]。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\f </TD>
<TD style="FONT-SIZE: 12px">匹配一个换页符。等价于 \x0c 和 \cL。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\n </TD>
<TD style="FONT-SIZE: 12px">匹配一个换行符。等价于 \x0a 和 \cJ。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\r </TD>
<TD style="FONT-SIZE: 12px">匹配一个回车符。等价于 \x0d 和 \cM。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\s </TD>
<TD style="FONT-SIZE: 12px">匹配任何空白字符，包括空格、制表符、换页符等等。等价于 [ \f\n\r\t\v]。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\S </TD>
<TD style="FONT-SIZE: 12px">匹配任何非空白字符。等价于 [^ \f\n\r\t\v]。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\t </TD>
<TD style="FONT-SIZE: 12px">匹配一个制表符。等价于 \x09 和 \cI。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\v </TD>
<TD style="FONT-SIZE: 12px">匹配一个垂直制表符。等价于 \x0b 和 \cK。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\w </TD>
<TD style="FONT-SIZE: 12px">匹配包括下划线的任何单词字符。等价于'[A-Za-z0-9_]'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\W </TD>
<TD style="FONT-SIZE: 12px">匹配任何非单词字符。等价于 '[^A-Za-z0-9_]'。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\xn </TD>
<TD style="FONT-SIZE: 12px">匹配 n，其中 n 为十六进制转义值。十六进制转义值必须为确定的两个数字长。例如，'\x41' 匹配 "A"。'\x041' 则等价于 '\x04' &amp; "1"。正则表达式中可以使用 ASCII 编码。.</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\num </TD>
<TD style="FONT-SIZE: 12px">匹配 num，其中 num 是一个正整数。对所获取的匹配的引用。例如，'(.)\1' 匹配两个连续的相同字符。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\n </TD>
<TD style="FONT-SIZE: 12px">标识一个八进制转义值或一个向后引用。如果 \n 之前至少 n 个获取的子表达式，则 n 为向后引用。否则，如果 n 为八进制数字 (0-7)，则 n 为一个八进制转义值。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\nm </TD>
<TD style="FONT-SIZE: 12px">标识一个八进制转义值或一个向后引用。如果 \nm 之前至少有 nm 个获得子表达式，则 nm 为向后引用。如果 \nm 之前至少有 n 个获取，则 n 为一个后跟文字 m 的向后引用。如果前面的条件都不满足，若 n 和 m 均为八进制数字 (0-7)，则 \nm 将匹配八进制转义值 nm。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\nml </TD>
<TD style="FONT-SIZE: 12px">如果 n 为八进制数字 (0-3)，且 m 和 l 均为八进制数字 (0-7)，则匹配八进制转义值 nml。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">\un </TD>
<TD style="FONT-SIZE: 12px">匹配 n，其中 n 是一个用四个十六进制数字表示的 Unicode 字符。例如， \u00A9 匹配版权符号 (?)。</TD></TR></TBODY></TABLE><STRONG>6. 部分例子<BR><BR></STRONG>
<TABLE cellSpacing=1 cellPadding=3 align=center bgColor=#eaeaea border=0>
<TBODY>
<TR bgColor=#f0f0f0>
<TH style="FONT-SIZE: 12px" align=left width=250 bgColor=#f0f0f0>正则表达式</TH>
<TH style="FONT-SIZE: 12px" align=left>说明</TH></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/\b([a-z]+) \1\b/gi</TD>
<TD style="FONT-SIZE: 12px">一个单词连续出现的位置</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)/ </TD>
<TD style="FONT-SIZE: 12px">将一个URL解析为协议、域、端口及相对路径</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/^(?:Chapter|Section) [1-9][0-9]{0,1}$/</TD>
<TD style="FONT-SIZE: 12px">定位章节的位置</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/[-a-z]/</TD>
<TD style="FONT-SIZE: 12px">A至z共26个字母再加一个-号。</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/ter\b/</TD>
<TD style="FONT-SIZE: 12px">可匹配chapter，而不能terminal</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/\Bapt/</TD>
<TD style="FONT-SIZE: 12px">可匹配chapter，而不能aptitude</TD></TR>
<TR bgColor=#fafafa>
<TD style="FONT-SIZE: 12px">/Windows(?=95 |98 |NT )/</TD>
<TD style="FONT-SIZE: 12px">可匹配Windows95或Windows98或WindowsNT,当找到一个匹配后，从Windows后面开始进行下一次的检索匹配。</TD></TR></TBODY></TABLE><STRONG>7. 正则表达式匹配规则<BR></STRONG><A name=71></A><BR>　　7.1 基本模式匹配<BR><BR>　　一切从最基本的开始。模式，是正规表达式最基本的元素，它们是一组描述字符串特征的字符。模式可以很简单，由普通的字符串组成，也可以非常复杂，往往用特殊的字符表示一个范围内的字符、重复出现，或表示上下文。例如：<BR><BR>　　^once <BR><BR>　 　这个模式包含一个特殊的字符^，表示该模式只匹配那些以once开头的字符串。例如该模式与字符串"once upon a time"匹配，与"There once was a man from NewYork"不匹配。正如如^符号表示开头一样，$符号用来匹配那些以给定模式结尾的字符串。<BR><BR>　　bucket$ <BR><BR>　　这个模式与"Who kept all of this cash in a bucket"匹配，与"buckets"不匹配。字符^和$同时使用时，表示精确匹配（字符串与模式一样）。例如：<BR><BR>　　^bucket$ <BR><BR>　　只匹配字符串"bucket"。如果一个模式不包括^和$，那么它与任何包含该模式的字符串匹配。例如：模式<BR><BR>　　once <BR><BR>　　与字符串<BR><BR>　　There once was a man from NewYork<BR>　　Who kept all of his cash in a bucket.<BR><BR>　　是匹配的。<BR><BR>　 　在该模式中的字母(o-n-c-e)是字面的字符，也就是说，他们表示该字母本身，数字也是一样的。其他一些稍微复杂的字符，如标点符号和白字符（空 格、制表符等），要用到转义序列。所有的转义序列都用反斜杠(\)打头。制表符的转义序列是：\t。所以如果我们要检测一个字符串是否以制表符开头，可以 用这个模式：<BR><BR>　　^\t <BR><BR>　　类似的，用\n表示“新行”，\r表示回车。其他的特殊符号，可以用在前面加上反斜杠，如反斜杠本身用\\表示，句号.用\.表示，以此类推。<BR><A name=72></A><BR>　　7.2 字符簇<BR><BR>　　在INTERNET的程序中，正规表达式通常用来验证用户的输入。当用户提交一个FORM以后，要判断输入的电话号码、地址、EMAIL地址、信用卡号码等是否有效，用普通的基于字面的字符是不够的。<BR><BR>　　所以要用一种更自由的描述我们要的模式的办法，它就是字符簇。要建立一个表示所有元音字符的字符簇，就把所有的元音字符放在一个方括号里：<BR><BR>　　[AaEeIiOoUu] <BR><BR>　　这个模式与任何元音字符匹配，但只能表示一个字符。用连字号可以表示一个字符的范围，如：<BR><BR>　　[a-z] //匹配所有的小写字母 <BR>　　[A-Z] //匹配所有的大写字母 <BR>　　[a-zA-Z] //匹配所有的字母 <BR>　　[0-9] //匹配所有的数字 <BR>　　[0-9\.\-] //匹配所有的数字，句号和减号 <BR>　　[ \f\r\t\n] //匹配所有的白字符 <BR><BR>　　同样的，这些也只表示一个字符，这是一个非常重要的。如果要匹配一个由一个小写字母和一位数字组成的字符串，比如"z2"、"t6"或"g7"，但不是"ab2"、"r2d3" 或"b52"的话，用这个模式：<BR><BR>　　^[a-z][0-9]$ <BR><BR>　　尽管[a-z]代表26个字母的范围，但在这里它只能与第一个字符是小写字母的字符串匹配。<BR><BR>　　前面曾经提到^表示字符串的开头，但它还有另外一个含义。当在一组方括号里使用^是，它表示“非”或“排除”的意思，常常用来剔除某个字符。还用前面的例子，我们要求第一个字符不能是数字：<BR><BR>　　^[^0-9][0-9]$ <BR><BR>　　这个模式与"&amp;5"、"g7"及"-2"是匹配的，但与"12"、"66"是不匹配的。下面是几个排除特定字符的例子：<BR><BR>　　[^a-z] //除了小写字母以外的所有字符 <BR>　　[^\\\/\^] //除了(\)(/)(^)之外的所有字符 <BR>　　[^\"\'] //除了双引号(")和单引号(')之外的所有字符 <BR><BR>　　特殊字符"." (点，句号)在正规表达式中用来表示除了“新行”之外的所有字符。所以模式"^.5$"与任何两个字符的、以数字5结尾和以其他非“新行”字符开头的字符串匹配。模式"."可以匹配任何字符串，除了空串和只包括一个“新行”的字符串。<BR><BR>　　PHP的正规表达式有一些内置的通用字符簇，列表如下：<BR><BR>　　字符簇含义 <BR><BR>　　[[:alpha:]] 任何字母 <BR>　　[[:digit:]] 任何数字 <BR>　　[[:alnum:]] 任何字母和数字 <BR>　　[[:space:]] 任何白字符 <BR>　　[[:upper:]] 任何大写字母 <BR>　　[[:lower:]] 任何小写字母 <BR>　　[[:punct:]] 任何标点符号 <BR>　　[[:xdigit:]] 任何16进制的数字，相当于[0-9a-fA-F] <BR><A name=73></A><BR>　　7.3 确定重复出现<BR><BR>　　到现在为止，你已经知道如何去匹配一个字母或数字，但更多的情况下，可能要匹配一个单词或一组数字。一个单词有若干个字母组成，一组数字有若干个单数组成。跟在字符或字符簇后面的花括号({})用来确定前面的内容的重复出现的次数。 <BR><BR>　　字符簇 含义 <BR>　　^[a-zA-Z_]$ 所有的字母和下划线 <BR>　　^[[:alpha:]]{3}$ 所有的3个字母的单词 <BR>　　^a$ 字母a <BR>　　^a{4}$ aaaa <BR>　　^a{2,4}$ aa,aaa或aaaa <BR>　　^a{1,3}$ a,aa或aaa <BR>　　^a{2,}$ 包含多于两个a的字符串 <BR>　　^a{2,} 如：aardvark和aaab，但apple不行 <BR>　　a{2,} 如：baad和aaa，但Nantucket不行 <BR>　　\t{2} 两个制表符 <BR>　　.{2} 所有的两个字符 <BR><BR>　 　这些例子描述了花括号的三种不同的用法。一个数字，{x}的意思是“前面的字符或字符簇只出现x次”；一个数字加逗号，{x,}的意思是“前面的内容出 现x或更多的次数”；两个用逗号分隔的数字，{x,y}表示“前面的内容至少出现x次，但不超过y次”。我们可以把模式扩展到更多的单词或数字：<BR><BR>　　^[a-zA-Z0-9_]{1,}$ //所有包含一个以上的字母、数字或下划线的字符串 <BR>　　^[0-9]{1,}$ //所有的正数 <BR>　　^\-{0,1}[0-9]{1,}$ //所有的整数 <BR>　　^\-{0,1}[0-9]{0,}\.{0,1}[0-9]{0,}$ //所有的小数 <BR><BR>　 　最后一个例子不太好理解，是吗？这么看吧：与所有以一个可选的负号(\-{0,1})开头(^)、跟着0个或更多的数字([0-9]{0,})、和一个 可选的小数点(\.{0,1})再跟上0个或多个数字([0-9]{0,})，并且没有其他任何东西($)。下面你将知道能够使用的更为简单的方法。<BR><BR>　　特殊字符"?"与{0,1}是相等的，它们都代表着：“0个或1个前面的内容”或“前面的内容是可选的”。所以刚才的例子可以简化为：<BR><BR>　　^\-?[0-9]{0,}\.?[0-9]{0,}$ <BR><BR>　　特殊字符"*"与{0,}是相等的，它们都代表着“0个或多个前面的内容”。最后，字符"+"与 {1,}是相等的，表示“1个或多个前面的内容”，所以上面的4个例子可以写成：<BR><BR>　　^[a-zA-Z0-9_]+$ //所有包含一个以上的字母、数字或下划线的字符串 <BR>　　^[0-9]+$ //所有的正数 <BR>　　^\-?[0-9]+$ //所有的整数 <BR>　　^\-?[0-9]*\.?[0-9]*$ //所有的小数 <BR><BR>　　当然这并不能从技术上降低正规表达式的复杂性，但可以使它们更容易阅读。<BR><img src ="http://www.blogjava.net/guming123416/aggbug/29002.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-01-23 13:11 <a href="http://www.blogjava.net/guming123416/archive/2006/01/23/29002.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在 Tomcat 上配置虚拟主机</title><link>http://www.blogjava.net/guming123416/archive/2006/01/13/27859.html</link><dc:creator>lovajava_ye</dc:creator><author>lovajava_ye</author><pubDate>Fri, 13 Jan 2006 02:22:00 GMT</pubDate><guid>http://www.blogjava.net/guming123416/archive/2006/01/13/27859.html</guid><wfw:comment>http://www.blogjava.net/guming123416/comments/27859.html</wfw:comment><comments>http://www.blogjava.net/guming123416/archive/2006/01/13/27859.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/guming123416/comments/commentRss/27859.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/guming123416/services/trackbacks/27859.html</trackback:ping><description><![CDATA[<P>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<P>一 准备<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 我们将配置两台虚拟主机，假设域名分别为<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.sentom1.net/">www.sentom1.net</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.sentom2.net/">www.sentom2.net</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 为了测试方便，请在客户机的:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Win2K:\\WINNT\system32\drivers\etc\hosts<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux:/etc/hosts<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文件中增加下面内容，然后检查一下这两个域名是否解析正确。 <BR>&nbsp;192.168.0.1&nbsp;<A href="http://www.sentom1.net/">www.sentom1.net</A><BR>&nbsp;192.168.0.1&nbsp;<A href="http://www.sentom2.net/">www.sentom2.net</A></P>
<P>当然，在生产环境中这样做是不行的，需要的在 DNS 上做相应的域名解析。 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 二 Tomcat安装<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tomcat <BR>的安装不在本文的讨论范围，请参考这里。请确保Tomcat安装正确，不然请不要继续进行下面的配置步骤。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将 tomcat 目录下的 webapps 目录在同一目录复制一份，目录名分为 webapps2 ，然后将 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webapps 目录改名 为 webapps1 。最后 tomcat 的目录结构大致如下： <BR>&nbsp;tomcat<BR>&nbsp;&nbsp;&nbsp; |--bin<BR>&nbsp;&nbsp;&nbsp; |--common<BR>&nbsp;&nbsp;&nbsp; |--conf<BR>&nbsp;&nbsp;&nbsp; |--logs<BR>&nbsp;&nbsp;&nbsp; |--server<BR>&nbsp;&nbsp;&nbsp; |--shared<BR>&nbsp;&nbsp;&nbsp; ......<BR>&nbsp;&nbsp;&nbsp; |--webpapps1<BR>&nbsp;&nbsp;&nbsp; |--webpapps2<BR>&nbsp;&nbsp;&nbsp; |--work</P>
<P>最后，写一个简单 html 文件用于测试，文件名为 test.html ，文件内容如下：</P>
<P>&lt;HTML&gt;<BR>&lt;HEAD&gt;<BR>&lt;TITLE&gt;测试&lt;/TITLE&gt;<BR>&lt;/HEAD&gt;</P>
<P>&lt;BODY&gt;<BR>&lt;P align="center"&gt;你现在访问的是 &lt;FONT COLOR="#FF0000"&gt;www.sentom1.net&lt;/FONT&gt;&lt;/P&gt;<BR>&lt;/BODY&gt;<BR>&lt;/HTML&gt;<BR>将 test.html 文件分别在 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tomcat/webapps1/ROOT、tomcat/webapps2/ROOT 目录放置一份，然后将 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tomcat/webapps2/ROOT/test.html <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文件内容中“www.sentom1.net”改为“www.sentom2.net”。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 至此，前期的准备工作做完了，全是一些体力活。 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 三 配置虚拟主机<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 前面提到了独立 IP 和共享的 IP。本文介绍的是共享的 IP 模式，这种模式就是所有的虚拟主机都使用同一 IP <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 。目前国内 IDC 提供的虚拟主机都是这种模式。这种模式的优点是节约数量有限的 IP ，缺点就是虚拟主 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 机只能通过域名访问而不能通过 IP 访问（其实也不算是缺点，只对邮件系统中用户的访问方式有一点点影响 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ）。而另外一种独立 IP 模式主要应用在邮件服务中，这里就不做介绍了。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 配置 <A href="http://www.sentom1.net/">www.sentom1.net</A> 虚拟主机</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 打开 tomcat/conf/server.xml 文件，将 Host <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 元素之间的内容全部删掉，然后把下面内容加如到 Host 元素 原来的位置。 <BR>&nbsp;&nbsp;&nbsp; &lt;Host name="<A href="http://www.sentom1.net/">www.sentom1.net</A>" debug="0" appBase="webapps1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unpackWARs="true" autoDeploy="true"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Valve className="org.apache.catalina.valves.AccessLogValve"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; directory="logs"&nbsp; prefix="sentom1_access_log." suffix=".txt"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pattern="common" resolveHosts="false"/&gt;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Logger className="org.apache.catalina.logger.FileLogger"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; directory="logs"&nbsp; prefix="sentom1_log." suffix=".txt"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timestamp="true"/&gt;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Host&gt;<BR>配置 <A href="http://www.sentom2.net/">www.sentom2.net</A> 虚拟主机</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将下面内容追加到 Host 元素后面，注意 Host 元素中 name 属性和 appBase 属性的值的变化。 </P>
<P>&nbsp;&nbsp;&nbsp; &lt;Host name="<A href="http://www.sentom2.net/">www.sentom2.net</A>" debug="0" appBase="webapps2"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unpackWARs="true" autoDeploy="true"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Valve className="org.apache.catalina.valves.AccessLogValve"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; directory="logs"&nbsp; prefix="sentom2_access_log." suffix=".txt"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pattern="common" resolveHosts="false"/&gt;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Logger className="org.apache.catalina.logger.FileLogger"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; directory="logs"&nbsp; prefix="sentom2_log." suffix=".txt"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timestamp="true"/&gt;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Host&gt;<BR>现在可以启动 Tomcat 了，分别访问<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.sentom1.net:8080/test.html">http://www.sentom1.net:8080/test.html</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.sentom2.net:8080/test.html">http://www.sentom2.net:8080/test.html</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果访问得到的页面内容分别是下面的内容，那表明虚拟主机已经配置成功了。否则，请检查你的配置过程并 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 重新按照文档配置。 <BR>你现在访问的是 <A href="http://www.sentom1.net/">www.sentom1.net</A><BR>你现在访问的是 <A href="http://www.sentom2.net/">www.sentom2.net</A></P></TD></TR></TBODY></TABLE></P><img src ="http://www.blogjava.net/guming123416/aggbug/27859.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/guming123416/" target="_blank">lovajava_ye</a> 2006-01-13 10:22 <a href="http://www.blogjava.net/guming123416/archive/2006/01/13/27859.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>