<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>somebody</title>
    <description></description>
    <link>http://somebody.javaeye.com</link>
    <language>UTF-8</language>
    <copyright>Copyright 2003-2008, JavaEye.com</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>JavaEye - 做最棒的软件开发交流社区</generator>
      <item>
        <title>Freebsd6.2下Trac10.4插件trac-webadmin安装</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/107421" style="color:red;">http://somebody.javaeye.com/blog/107421</a>&nbsp;
          发表时间: 2007年07月31日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          Trac提供了一个web管理的plugin:<a href="http://trac.edgewall.org/wiki/WebAdmin">Web Admin Plugin</a> ,在freebsd里面安装非常简单。<br />
<code> dev# cd /usr/ports/www/trac-webadmin/ <br />
dev# make install clean </code> <br />
这样就安装好了。接下来的工作就是要设置一下你的trac项目了。给trac.ini添加webadmin的配置。<br />
<code> dev# cd /trac/projects/conf dev# vi trac.ini <br />
[components] <br />
webadmin.* = enabled </code> <br />
接下来需要设置用户的权限。用户需要有TRAC_ADMIN权限才能使用webadmin管理项目。<br />
<code> dev# trac-admin /path/to/projenv permission add rory TRAC_ADMIN </code> <br />
一切都ok了。让我们重启一下apache。<br />
<code> dev# /usr/local/etc/rc.d/apache22 restart </code> <br />
浏览 http://you.host.nameOrIP/trac 用具有TRAC_ADMIN权限的用户登录(rory).登录之后你就可以看到最上面的tab多了一个admin。这样就可以进行web管理了。还有一个 好消息就是0.11已经默认集成了这个plugin，以后不需要单独再装了。期待0.11的发布吧。<br />
效果如下图。<br />
<br />
<a href="http://photo8.yupoo.com/20070730/234243_1389617064_edtmlrlh.jpg"><img src="http://photo8.yupoo.com/20070730/234243_1389617064.jpg" alt="Trac0.10.4 web admin" /></a><br />
<br />
转载请注明来自 <br />
<a href="http://jdkcn.com/entry/trac0104-trac-web-admin-plugin-howto.html" target="_blank">http://jdkcn.com/entry/trac0104-trac-web-admin-plugin-howto.html</a>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/107421#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 31 Jul 2007 17:38:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/107421</link>
        <guid>http://somebody.javaeye.com/blog/107421</guid>
      </item>
      <item>
        <title>在Freebsd6.2下架设Apache2.2+Subversion1.4.3+Trac0.10.4作为版本控制缺陷跟踪</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/92157" style="color:red;">http://somebody.javaeye.com/blog/92157</a>&nbsp;
          发表时间: 2007年06月19日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>首先安装Freebsd系统，我安装的是6.2。建议只安装src,ports,binary,doc.其他ports里面的package先不要 装，升级一下ports之后再装。因为前不久ports里面的xorg从6.9升级到7.2了。如果安装了升级比较麻烦。所以先不安装其他的 package。<br />
<br />
升级ports之后开始安装。<br />
</p>
<p>首先我们需要安装 Apache 和 Subversion 软件：</p>
<pre>dev# cd /usr/ports/www/apache22<br />dev# make WITH_AUTH_MODULES=yes WITH_DAV_MODULES=yes \<br />                     WITH_SSL_MODULES=yes WITH_BERKELEYDB=db42 install clean<br />dev# cd /usr/ports/devel/subversion<br />dev# make -DWITH_SVNSERVE_WRAPPER -DWITH_MOD_DAV_SVN \<br />                     -DWITH_APACHE2_APR install clean<br /></pre>
<p>安装完成后，我们来初始化仓库目录：</p>
<pre>dev# mkdir -p /svn/repos<br />dev# svnadmin create /svn/repos<br />dev# chown -R www:www /svn/repos<br /></pre>
<p>这里，使用 www:www 用户/组是由于我们是通过 Apache 来提供访问支持。设置 Apache 的配置文件 /usr/local/etc/apache22/httpd.conf，以下只显示了主体部分：</p>
<pre>.....<br />LoadModule usertrack_module libexec/apache22/mod_usertrack.so<br />LoadModule unique_id_module libexec/apache22/mod_unique_id.so<br />LoadModule setenvif_module libexec/apache22/mod_setenvif.so<br />LoadModule version_module libexec/apache22/mod_version.so<br />LoadModule ssl_module libexec/apache22/mod_ssl.so<br />LoadModule mime_module libexec/apache22/mod_mime.so<br />LoadModule dav_module libexec/apache22/mod_dav.so<br />LoadModule status_module libexec/apache22/mod_status.so<br />LoadModule autoindex_module libexec/apache22/mod_autoindex.so<br />LoadModule asis_module libexec/apache22/mod_asis.so<br />LoadModule info_module libexec/apache22/mod_info.so<br />.......<br />LoadModule alias_module libexec/apache22/mod_alias.so<br />LoadModule rewrite_module libexec/apache22/mod_rewrite.so<br />#LoadModule dav_module         libexec/apache22/mod_dav.so<br />LoadModule dav_svn_module     libexec/apache22/mod_dav_svn.so<br />LoadModule authz_svn_module   libexec/apache22/mod_authz_svn.so<br /><br /><br /></pre>
重启apache的时候发现有一个dav_module的错误。后来发现是load了两次。我就把后面的那个dav_module注释掉了。注意注释前面的那个会出错的。<br />
然后在/usr/local/etc/apache22/Includes 下编辑svn.conf<br />
<pre>dev# vi /usr/local/etc/apache22/Includes/svn.conf<br />&lt;Location /svn&gt;<br />DAV svn<br />SVNPath /svn/repos<br />AuthType Basic<br />AuthName &quot;Feloo Subversion Repository&quot;<br />AuthUserFile /etc/svn-auth-file<br />Require valid-user<br />&lt;/Location&gt;<br /><br /></pre>
<p>使用 htpasswd 创建验证用户：</p>
<pre>dev# htpasswd -cm /etc/svn-auth-file rory<br /></pre>
<p>最后，在 /etc/rc.conf 文件中设置：</p>
<pre>apache22_enable=&quot;YES&quot; <br /></pre>
<p>启动 Apache 后，可以通过 http://you.host.nameOrIP/svn 访问你的 Subversion 仓库了（这里假设你的 Apache 监听在 80 端口）。至于客户端，在 Windows 下可以使用 <a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVNn</a>，相当不错工具。以上步骤在 FreeBSD 6.1-RC 环境下试验成功，你可以进行适当的设置，让 Apache 支持 <span class="caps">SSL</span>，这样，你的 svn 将更加安全。</p>
接下来安装trac<br />
<br />
<pre>dev# cd /usr/ports/www/trac<br /><br />dev# make install clean<br /><br /></pre>
<br />
这样就安装好了，简单吧。接下来开始initevn<br />
<pre>dev# mkdir -p /trac/projects/<br /><br />dev# trac-admin /trac/projects initenv<br /><br />dev# chown -R www:www /trac/projects/ (这一步很重要哦。如果没有修改owner下面和Apache集成之后会<br /><br />出现没有权限的错误不能正常显示)<br /><br /></pre>
<br />
操作中会提示一些信息，提示subversion 的 repository地址就是前面我们创建的repository /svn/repos 其他都不用设置这样就建立好了,启动standalone服务器tracd<br />
<pre>dev# tracd --port 8000 /trac/projects<br /><br /></pre>
这样就可以通过http://you.host.nameOrIP:8000 查看到安装成功的trac了.这算是基本完成了。接下来就是使用apache来运行trac,需要<a href="http://trac.edgewall.org/wiki/TracModPython" class="wiki">mod_python</a> 或者 <a href="http://trac.edgewall.org/wiki/TracModWSGI" class="wiki">mod_wsgi</a> 的支持。这里我选择了mod_python,因为在ports里面有现成的。<br />
<pre>dev# cd /usr/ports/www/mod_python3<br /><br />dev# make install clean<br /><br /></pre>
这里不能安装/usr/ports/www/mod_python 因为这里需要mod_python 3.1.3+ /usr/ports/www/mod_python 的版本是 2.7.11。<br />
安装完成之后修改Apache的配置加载安装好的mod_python.<br />
<pre>dev# vi /usr/local/etc/apache22/httpd.conf <br /><br />LoadModule python_module libexec/apache22/mod_python.so<br /><br /></pre>
添加trac的Location配置<br />
<pre>dev# vi /usr/local/etc/apache22/Includes/trac.conf <br /><br />&lt;Location /trac&gt;<br />  SetHandler mod_python<br />  PythonHandler trac.web.modpython_frontend<br />  PythonOption TracEnv /trac/projects<br />  PythonOption TracUriRoot /trac<br />&lt;/Location&gt;<br />&lt;Location /trac/login&gt;<br />  AuthType Basic<br />  AuthName &quot;Feloo Trac Projects&quot;<br />  AuthUserFile /etc/svn-auth-file<br />  Require valid-user<br />&lt;/Location&gt;<br /><br /></pre>
这里使用的认证文件和svn的相同。一切都ok了,重启Apache<br />
dev# /usr/local/etc/rc.d/apache22 restart<br />
查看http://you.host.nameOrIP/trac 一切正常,恭喜你安装成功了。<br />
<h2>参考</h2>
<br />
<a href="http://www.dirk.sh/diary/255" title="在 FreeBSD 下架设 Subversion 作为版本控制系统">在 FreeBSD 下架设 Subversion 作为版本控制系统</a><br />
<br />
本文系 <a href="http://jdkcn.com/">莫多泡泡(somebody)</a> 原创，转载请注明地址和作者。谢谢。<br />
<a href="http://jdkcn.com/entry/howto-install-apache22-subversion143-trac10-on-freebsd6.html">http://jdkcn.com/entry/howto-install-apache22-subversion143-trac10-on-freebsd6.html</a>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/92157#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 19 Jun 2007 21:05:59 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/92157</link>
        <guid>http://somebody.javaeye.com/blog/92157</guid>
      </item>
      <item>
        <title>Myblog1.0GA(端午节)发布</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/92155" style="color:red;">http://somebody.javaeye.com/blog/92155</a>&nbsp;
          发表时间: 2007年06月19日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>前几天有几个网友又在询问Myblog不能下载的问题。今天修复了剩下的几个bug，准备发布1.0版本。赶巧今天是端午节。大家吃粽子了么？我刚吃过。<img src="http://jdkcn.com/FCK/editor/images/smiley/msn/teeth_smile.gif" alt="" /><br />
&nbsp; 这里给几张1.0版本的截图。<br />
</p>
<ol>
    <li>&nbsp; 登录界面</li>
    <br />
    <a href="http://photo8.yupoo.com/20070619/175247_1523292231_ddmrtmzd.jpg"><img src="http://photo8.yupoo.com/20070619/175247_1523292231_m.jpg" alt="Myblog 1.0 Login" /></a><br />
    <li>&nbsp; 站点配置页面</li>
    <a href="http://photo8.yupoo.com/20070619/175244_1685776285_cdxzzuzq.jpg"><img src="http://photo8.yupoo.com/20070619/175244_1685776285_m.jpg" alt="Myblog 1.0 Site Config" /></a><br />
    <li>&nbsp; 发表日志页面</li>
    <a href="http://photo6.yupoo.com/20070619/175243_580787099_zzulsqwb.jpg"><img src="http://photo6.yupoo.com/20070619/175243_580787099_m.jpg" alt="Myblog 1.0 Post Blog" /></a><br />
    <li>&nbsp; 后台控制面板</li>
    <a href="http://photo6.yupoo.com/20070619/175242_713773323_tahupuoy.jpg"><img src="http://photo6.yupoo.com/20070619/175242_713773323.jpg" alt="Myblog 1.0 Administration Panel" /></a><br />
    <li>&nbsp; 默认前台页面</li>
    <a href="http://photo6.yupoo.com/20070619/175246_158322714_hbopicor.jpg"><img src="http://photo6.yupoo.com/20070619/175246_158322714.jpg" alt="Myblog 1.0 Default theme" /></a><br />
    <li>&nbsp; itheme 前台页面</li>
    <a href="http://photo6.yupoo.com/20070619/175911_880936606_mbgqrftu.jpg"><img src="http://photo6.yupoo.com/20070619/175911_880936606.jpg" alt="Myblog 1.0 itheme view" /></a><br />
    <br />
</ol>
最后给出下载地址<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 下载地址一&nbsp; <a href="http://code.google.com/p/myblog/downloads/list">googlecode.com</a><br />
&nbsp;&nbsp;&nbsp;&nbsp; 下载地址二&nbsp; <a href="http://jdkcn.com/download.htm">http://jdkcn.com/download.htm</a><br />
<br />
使用站点<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://jdkcn.com/">莫多泡泡(itheme)</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.5iditu.com/">我爱地图(default theme)</a><br />
<br />
<a href="http://jdkcn.com/entry/Myblog1-GA-Dragon-Boat-Festival-Release.html" target="_blank">http://jdkcn.com/entry/Myblog1-GA-Dragon-Boat-Festival-Release.html</a>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/92155#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 19 Jun 2007 20:59:27 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/92155</link>
        <guid>http://somebody.javaeye.com/blog/92155</guid>
      </item>
      <item>
        <title>Ubuntu Feisty下SSH连接缓慢的解决方法</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/89535" style="color:red;">http://somebody.javaeye.com/blog/89535</a>&nbsp;
          发表时间: 2007年06月12日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          &nbsp;&nbsp;&nbsp;&nbsp; 在Ubuntu Feisty刚发布没多久就从Edgy 升级到了Feisty,不过升级之后ssh变得非常的买。但是连接局域网的时候又不慢。刚开始以为可能是升级不完全的原因，就将就用了。不过我每天都要用 到ssh，真的那个不爽ing。后来还尝试找一些gui的软件来替代。想到了putty，不过是基于QT的不喜欢，后来还找到一个bbs的client, 支持ssh的。叫bbman,可惜源里面没有，下载下来的依赖库版本又比较老了跑不起来。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 今天终于找到了解决方法，前两天才发现这是一个bug，forum.ubuntu.org.cn 有个人升级到7.10的白鼠说的。他升级到7.10就没有这个问题了。今天在ubuntu的bug里面找到了解决方法。解决方法其实很简单。<br />
&nbsp;&nbsp; 把/etc/ssh/ssh_config里面的GSSAPIAuthentication修改成no就ok了。<br />
&nbsp;&nbsp; GSSAPIAuthentication no<br />
<br />
<br />
转载请注明出处。<a href="http://jdkcn.com/entry/howto-solve-ubuntu-feisty-ssh-slow-problem.html">http://jdkcn.com/entry/howto-solve-ubuntu-feisty-ssh-slow-problem.html</a>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/89535#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 12 Jun 2007 20:16:03 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/89535</link>
        <guid>http://somebody.javaeye.com/blog/89535</guid>
      </item>
      <item>
        <title>xstream对xmlnode的属性(attribute)解析的问题。</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/48228" style="color:red;">http://somebody.javaeye.com/blog/48228</a>&nbsp;
          发表时间: 2007年01月17日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          xstream是个好东西。对于配置文件的读取很方便。在mybog中我就用到了。不过今天打算用yupoo的api来做相册。发现xstream对于xmlnode的attribute解析支持不是那么的好。<br />对于这种节点格式的非常的简单<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">result</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">page</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">1</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">page</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">pages</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">1</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">pages</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">perpage</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">100</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">perpage</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">total</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">19</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">total</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">photos</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">photo</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">id</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">ff8080810fc8ac78010fd3f158d40a52</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">id</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">owner</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">ff8080810f1a387b010f1a83d6530dfc</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">owner</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">title</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">Gmail-2</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">title</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">host</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">4</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">host</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">dir</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">20061230</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">dir</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">filename</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">231905_1463411198</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">filename</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">photo</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">photos</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">result</span><span style="COLOR: #0000ff">&gt;</span></div><br />简单的alias一下就可以读到值了<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">File file </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> File(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">src/test/java/com/jdkcn/test/result.xml</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />BufferedReader reader </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> BufferedReader(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> InputStreamReader(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> FileInputStream(file), </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">UTF-8</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />XStream stream </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> XStream();<br />stream.alias(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">result</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, YupooResult.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);<br />stream.alias(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">photo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,YupooPhoto.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);<br />YupooResult result </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (YupooResult)stream.fromXML(reader);</span></div>可是Yupoo的api返回的xmlrpc的结果是这样的<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">result </span><span style="COLOR: #ff0000">page</span><span style="COLOR: #0000ff">="1"</span><span style="COLOR: #ff0000"> pages</span><span style="COLOR: #0000ff">="1"</span><span style="COLOR: #ff0000"> perpage</span><span style="COLOR: #0000ff">="100"</span><span style="COLOR: #ff0000"> total</span><span style="COLOR: #0000ff">="19"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">photos</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">photo </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="ff8080810fc8ac78010fd3f158d40a52"</span><span style="COLOR: #ff0000"><br />            owner</span><span style="COLOR: #0000ff">="ff8080810f1a387b010f1a83d6530dfc"</span><span style="COLOR: #ff0000"> title</span><span style="COLOR: #0000ff">="Gmail-2"</span><span style="COLOR: #ff0000"> host</span><span style="COLOR: #0000ff">="4"</span><span style="COLOR: #ff0000"><br />            dir</span><span style="COLOR: #0000ff">="20061230"</span><span style="COLOR: #ff0000"> filename</span><span style="COLOR: #0000ff">="231905_1463411198"</span><span style="COLOR: #ff0000"> </span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">photos</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">result</span><span style="COLOR: #0000ff">&gt;</span></div>这样就load不到值了。没法去mailist里面找答案，果然有人问。<br /><pre><font color="#ff9900">Hello,

I am not sure about the subject but here is what I needed help for:

XML:

&lt;field name="value"&gt;I am a Field.&lt;/field&gt;

I have already tried several structures and nothing seem to work.

Is this possible for XStream? :)

How is the Java class form to support this?

Thanks!</font><br /><br /><br /><br /><br />有人回答是看Converter的文档。果然找到答案了。<br />自己写一个converter就可以了。<br />下面是我的converter<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> com.jdkcn.xstream;<br /><br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.util.ArrayList;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.util.List;<br /><br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.jdkcn.yupoo.YupooPhoto;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.jdkcn.yupoo.YupooResult;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.thoughtworks.xstream.converters.Converter;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.thoughtworks.xstream.converters.MarshallingContext;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.thoughtworks.xstream.converters.UnmarshallingContext;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.thoughtworks.xstream.io.HierarchicalStreamReader;<br /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.thoughtworks.xstream.io.HierarchicalStreamWriter;<br /><br /></span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /> * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> &lt;a href="mailto:rory.cn@gmail.com"&gt;somebody&lt;/a&gt;<br /> * </span><span style="COLOR: #808080">@since</span><span style="COLOR: #008000"> Jan 16, 2007 6:12:35 PM<br /> * </span><span style="COLOR: #808080">@version</span><span style="COLOR: #008000"> $Id YupooResultConverter.java$<br /> </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> YupooResultConverter </span><span style="COLOR: #0000ff">implements</span><span style="COLOR: #000000"> Converter {<br />    </span><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"> (non-Javadoc)<br />     * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext)<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {<br />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> FIXME unfinish.</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">    }<br /><br />    </span><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"> (non-Javadoc)<br />     * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.UnmarshallingContext)<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {<br />        YupooResult result </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> YupooResult();<br />        result.setPage(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Integer(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">page</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)));<br />        result.setPages(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Integer(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pages</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)));<br />        result.setPerpage(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Integer(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">perpage</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)));<br />        result.setTotal(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Integer(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">total</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)));<br />        reader.moveDown();<br />        List</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">YupooPhoto</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> photos </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">YupooPhoto</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">();<br />        </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(reader.hasMoreChildren()) {<br />            reader.moveDown();<br />            YupooPhoto photo </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> YupooPhoto();<br />            photo.setDir(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">dir</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />            photo.setFilename(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">filename</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />            photo.setHost(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">host</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />            photo.setId(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />            photo.setOwner(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">owner</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />            photo.setTitle(reader.getAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">title</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br />            photos.add(photo);<br />            reader.moveUp();<br />        }<br />        result.setPhotos(photos);<br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> result;<br />    }<br />    </span><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"> (non-Javadoc)<br />     * @see com.thoughtworks.xstream.converters.ConverterMatcher#canConvert(java.lang.Class)<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000"> canConvert(Class clazz) {<br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> clazz.equals(YupooResult.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);<br />    }<br />}<br /></span></div><br />然后调用的地方修改一下就ok了。<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">XStream stream </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> XStream();<br />stream.registerConverter(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> YupooResultConverter());<br />stream.alias(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">result</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, YupooResult.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);</span></div><br /><br />以后大家一定要注意啊。顺序问题也是很重要的。<br /><a href="http://www.creativecommons.cn/licenses/by-nc-sa/1.0/" target="_blank"><img src="http://leaf.jdk.cn/rights.gif" border="0" height="31" alt="创造共用协议:署名,非商业,保持一致" width="88" /></a>   除经特别注明外,本文章版权归<strong><a href="http://jdkcn.com/" class=""><font color="#6b6b52">莫多泡泡</font></a></strong>所有. <br /><font color="#ff0000">署名,非商业用途,保持一致.</font>   <a href="http://jdkcn.com/" title="莫多泡泡" target="_blank">somebody(莫多)</a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />参考:<br /><a href="http://xstream.codehaus.org/converter-tutorial.html">http://xstream.codehaus.org/converter-tutorial.html</a><br /><br /><br /><br /><br /><br /><br /><br /><br /></pre><img src="http://www.blogjava.net/rory/aggbug/94475.html" height="1" width="1" /><br /><br /><div align="right"><a href="http://www.blogjava.net/rory/" target="_blank" style="text-decoration:none;">莫多</a> 2007-01-17 18:24 <a href="http://www.blogjava.net/rory/archive/2007/01/17/howto-dealwith-xstream-xmlnode-attribute.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/48228#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Wed, 17 Jan 2007 10:24:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/48228</link>
        <guid>http://somebody.javaeye.com/blog/48228</guid>
      </item>
      <item>
        <title>又是乱码问题-Filter 配置也很重要</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/45871" style="color:red;">http://somebody.javaeye.com/blog/45871</a>&nbsp;
          发表时间: 2006年12月27日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>  上周更新了一下myblog,添加了一个Filter，做统计访问用。可是后来发现出现乱码问题了。找了很久都没有找到问题。debug的时候看到 CharacterEncodingFilter确实是执行了。不过就是没有效果。执行之前是ISO-8859-1编码的，执行之后还是， CharacterEncodingFilter就没有起到作用。后来终于找到问题的原因了。原来是Filter配置先后顺序的原因。<br />       刚开始的配置是这样的:<br /></p>
    <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)">
        <span style="COLOR: rgb(0,0,0)">    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">requestCounterFilter</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">*.jhtml</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
        </span>
        <span style="COLOR: rgb(0,0,255)">
            <span style="COLOR: rgb(0,0,0)">
                <br />   <br />    </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />        </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">filter-name</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">encodingFilter</span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">filter-name</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />        </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">url-pattern</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">/dwr/*</span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">url-pattern</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />    </span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />    <br />    </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />        </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">filter-name</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">encodingFilter</span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">filter-name</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />        </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">url-pattern</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">*.jhtml</span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">url-pattern</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />    </span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />    <br />    </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />        </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">filter-name</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">encodingFilter</span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">filter-name</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />        </span>
            <span style="COLOR: rgb(0,0,255)">&lt;</span>
            <span style="COLOR: rgb(128,0,0)">url-pattern</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">*.jsp</span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">url-pattern</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
            <span style="COLOR: rgb(0,0,0)">
                <br />    </span>
            <span style="COLOR: rgb(0,0,255)">&lt;/</span>
            <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
            <span style="COLOR: rgb(0,0,255)">&gt;</span>
        </span>
    </div>
    <p>  先经过那个统计的filter然后再经过编码的filter。这样的话编码的filter就不起作用了。只要吧编码的filter放到最前面就没有问题了。改成这样就好。<br /></p>
    <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)">
        <span style="COLOR: rgb(0,0,0)">    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">encodingFilter</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">/dwr/*</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">encodingFilter</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">*.jhtml</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">encodingFilter</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">*.jsp</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">requestCounterFilter</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-name</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />        </span>
        <span style="COLOR: rgb(0,0,255)">&lt;</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">*.jhtml</span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">url-pattern</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
        <span style="COLOR: rgb(0,0,0)">
            <br />    </span>
        <span style="COLOR: rgb(0,0,255)">&lt;/</span>
        <span style="COLOR: rgb(128,0,0)">filter-mapping</span>
        <span style="COLOR: rgb(0,0,255)">&gt;</span>
    </div>
    <p>
        <br />以后大家一定要注意啊。顺序问题也是很重要的。<br /><a href="http://www.creativecommons.cn/licenses/by-nc-sa/1.0/" target="_blank"><img src="http://leaf.jdk.cn/rights.gif" border="0" height="31" alt="创造共用协议:署名,非商业,保持一致" width="88" /></a>   除经特别注明外,本文章版权归<strong><a href="http://jdkcn.com/" class=""><font color="#6b6b52">莫多泡泡</font></a></strong>所有. <br /><font color="#ff0000">署名,非商业用途,保持一致.</font>   <a href="http://jdkcn.com/" title="莫多泡泡" target="_blank">somebody(莫多)</a></p><img src="http://www.blogjava.net/rory/aggbug/90236.html" height="1" width="1" /><br /><br /><div align="right"><a href="http://www.blogjava.net/rory/" target="_blank" style="text-decoration:none;">莫多</a> 2006-12-27 10:37 <a href="http://www.blogjava.net/rory/archive/2006/12/27/character_encoding_problem_filtermapping_position.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/45871#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Wed, 27 Dec 2006 02:37:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/45871</link>
        <guid>http://somebody.javaeye.com/blog/45871</guid>
      </item>
      <item>
        <title>又是乱码问题-Filter 配置也很重要</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/45579" style="color:red;">http://somebody.javaeye.com/blog/45579</a>&nbsp;
          发表时间: 2006年12月27日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 上周更新了一下myblog,添加了一个Filter，做统计访问用。可是后来发现出现乱码问题了。找了很久都没有找到问题。debug的时候看到CharacterEncodingFilter确实是执行了。不过就是没有效果。执行之前是ISO-8859-1编码的，执行之后还是，CharacterEncodingFilter就没有起到作用。后来终于找到问题的原因了。原来是Filter配置先后顺序的原因。<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 刚开始的配置是这样的:<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">requestCounterFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.jhtml</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">encodingFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/dwr/*</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">encodingFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.jhtml</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">encodingFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span></span></div>
&nbsp; 先经过那个统计的filter然后再经过编码的filter。这样的话编码的filter就不起作用了。只要吧编码的filter放到最前面就没有问题了。改成这样就好。<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">encodingFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/dwr/*</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">encodingFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.jhtml</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">encodingFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">requestCounterFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.jhtml</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
<br />以后大家一定要注意啊。顺序问题也是很重要的。<br /><a href="http://www.creativecommons.cn/licenses/by-nc-sa/1.0/" target="_blank"><img src="http://leaf.jdk.cn/rights.gif" border="0" height="31" alt="创造共用协议:署名,非商业,保持一致" width="88" /></a>&nbsp;&nbsp; 除经特别注明外,本文章版权归<strong><a href="http://jdkcn.com/../../" class=""><font color="#6b6b52">莫多泡泡</font></a></strong>所有. <br /><font color="#ff0000">署名,非商业用途,保持一致.</font>&nbsp;&nbsp;&nbsp;<a href="http://jdkcn.com/../../" title="莫多泡泡" target="_blank">somebody(莫多)</a>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/45579#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Wed, 27 Dec 2006 02:35:33 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/45579</link>
        <guid>http://somebody.javaeye.com/blog/45579</guid>
      </item>
      <item>
        <title>tuckey urlrewrite 3.x的问题</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/38652" style="color:red;">http://somebody.javaeye.com/blog/38652</a>&nbsp;
          发表时间: 2006年12月12日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          昨天晚上配置myblog的rewrite。发现一个奇怪的问题。由于现在使用的这个pjblog，为了让搜索引擎收录的连接有效。我想把原来的asp连接rewrite到我的新程序上面。所以有这样一条规则。<br />
<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">^/article.asp\?id=(.*)$</span><span style="color: rgb(0, 0, 255);"><!--</span--><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">to&nbsp;</span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">=&quot;redirect&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/entry/$1.jhtml</span><span style="color: rgb(0, 0, 255);"><!--</span--><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);"><!--</span--><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span></span></span></span></div>
&nbsp;&nbsp;&nbsp;&nbsp;  但是我这样的连接总是匹配不到，只要去掉那个？就可以了。这个正则表达式是没有问题的。/article.asp?id=64是可以匹配的到的。<br />
&nbsp;&nbsp;&nbsp;  后来看3.0的manual (http://tuckey.org/urlrewrite/manual/3.0/)才发现原来是这个的问题。<br />
<h3><urlrewrite> element</urlrewrite></h3>
<p>The top level element.</p>
<table cellspacing="0">
    <tbody>
        <tr>
            <th>Attribute</th>
            <th>Possible Value</th>
            <th>Explanation</th>
        </tr>
        <tr>
            <td rowspan="2">default-match-type <br />
            <small>(optional)</small></td>
            <td><strong>regex</strong> (default)</td>
            <td>All rules and thier conditions will be processed using the Java Regular  Expression engine (unless <code>match-type</code> is specified on a  rule).</td>
        </tr>
        <tr>
            <td>wildcard</td>
            <td>All rules and thier conditions will be processed using the <a href="http://tuckey.org/urlrewrite/manual/3.0/#wildcard">Wildcard Expression  engine</a> (unless <code>match-type</code> is specified on a rule).</td>
        </tr>
        <tr>
            <td rowspan="3">decode-using <br />
            <small>(optional)</small></td>
            <td><strong>utf8</strong> (default)</td>
            <td>When URL is decoded UTF-8 will be used.</td>
        </tr>
        <tr>
            <td>null</td>
            <td>Do not decode.</td>
        </tr>
        <tr>
            <td>[encoding]</td>
            <td>Any string representing a supported character encoding eg, ISO-8859-1. See  <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Java  Charset Object</a> for more info. </td>
        </tr>
        <tr>
            <td rowspan="2" style="font-weight: bold; color: rgb(0, 0, 255);">use-query-string  <br />
            <small>(optional)</small></td>
            <td><strong>false</strong> (default)</td>
            <td>The query string will <em>not</em> be appended to the url that the &quot;from&quot;  element matches against.</td>
        </tr>
        <tr>
            <td>true</td>
            <td>The query string will be appended to the url that the &quot;from&quot; element matches  against.</td>
        </tr>
        <tr>
            <td rowspan="2">use-context <br />
            <small>(optional)</small></td>
            <td><strong>false</strong> (default)</td>
            <td>The context path will <em>not</em> be added to the url that the &quot;from&quot;  element matches against.</td>
        </tr>
        <tr>
            <td>true</td>
            <td>The context path will be added to the url that the &quot;from&quot; element matches  against.</td>
        </tr>
    </tbody>
</table>
<br />
就是那个use-query-string  的问题，默认的是不使用query-string就是把?后面的都忽略了。所以就不能匹配到了。只要在<urlrewrite>里面加一个属性就可以了。<br />
</urlrewrite>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">urlrewrite&nbsp;</span><span style="color: rgb(255, 0, 0);">use-query-string</span><span style="color: rgb(0, 0, 255);">=&quot;true&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;<img src="/Images/dot.gif" alt="" /><br />
</span><span style="color: rgb(0, 0, 255);"><!--</span--><span style="color: rgb(128, 0, 0);">urlrewrite</span><span style="color: rgb(0, 0, 255);">&gt;</span></span></div>
<p>&nbsp;</p>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/38652#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 12 Dec 2006 10:43:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/38652</link>
        <guid>http://somebody.javaeye.com/blog/38652</guid>
      </item>
      <item>
        <title>tuckey urlrewrite 3.x的问题</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/45872" style="color:red;">http://somebody.javaeye.com/blog/45872</a>&nbsp;
          发表时间: 2006年12月12日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          昨天晚上配置myblog的rewrite。发现一个奇怪的问题。由于现在使用的这个pjblog，为了让搜索引擎收录的连接有效。我想把原来的asp连接rewrite到我的新程序上面。所以有这样一条规则。<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">    </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">rule</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />        </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">from</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)">^/article.asp\?id=(.*)$</span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">from</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />        </span><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">to </span><span style="COLOR: rgb(255,0,0)">type</span><span style="COLOR: rgb(0,0,255)">="redirect"</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)">/entry/$1.jhtml</span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">to</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    </span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">rule</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div>     但是我这样的连接总是匹配不到，只要去掉那个？就可以了。这个正则表达式是没有问题的。/article.asp?id=64是可以匹配的到的。<br />    后来看3.0的manual (http://tuckey.org/urlrewrite/manual/3.0/)才发现原来是这个的问题。<br /><h3>&lt;urlrewrite&gt; element</h3><p>The top level element.</p><table cellspacing="0"><tbody><tr><th>Attribute</th><th>Possible Value</th><th>Explanation</th></tr><tr><td rowspan="2">default-match-type <br /><small>(optional)</small></td><td><b>regex</b> (default)</td><td>All rules and thier conditions will be processed using the Java Regular Expression engine (unless <code>match-type</code> is specified on a rule).</td></tr><tr><td>wildcard</td><td>All rules and thier conditions will be processed using the <a href="http://tuckey.org/urlrewrite/manual/3.0/#wildcard">Wildcard Expression engine</a> (unless <code>match-type</code> is specified on a rule).</td></tr><tr><td rowspan="3">decode-using <br /><small>(optional)</small></td><td><b>utf8</b> (default)</td><td>When URL is decoded UTF-8 will be used.</td></tr><tr><td>null</td><td>Do not decode.</td></tr><tr><td>[encoding]</td><td>Any string representing a supported character encoding eg, ISO-8859-1. See <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Java Charset Object</a> for more info. </td></tr><tr><td rowspan="2" style="FONT-WEIGHT: bold; COLOR: rgb(0,0,255)">use-query-string <br /><small>(optional)</small></td><td><b>false</b> (default)</td><td>The query string will <em>not</em> be appended to the url that the "from" element matches against.</td></tr><tr><td>true</td><td>The query string will be appended to the url that the "from" element matches against.</td></tr><tr><td rowspan="2">use-context <br /><small>(optional)</small></td><td><b>false</b> (default)</td><td>The context path will <em>not</em> be added to the url that the "from" element matches against.</td></tr><tr><td>true</td><td>The context path will be added to the url that the "from" element matches against.</td></tr></tbody></table><br />就是那个use-query-string 的问题，默认的是不使用query-string就是把?后面的都忽略了。所以就不能匹配到了。只要在&lt;urlrewrite&gt;里面加一个属性就可以了。<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">urlrewrite </span><span style="COLOR: rgb(255,0,0)">use-query-string</span><span style="COLOR: rgb(0,0,255)">="true"</span><span style="COLOR: rgb(0,0,255)">&gt;</span><span style="COLOR: rgb(0,0,0)"><br />    <img src="http://www.blogjava.net/images/dot.gif" alt="" /><br /></span><span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">urlrewrite</span><span style="COLOR: rgb(0,0,255)">&gt;</span></div><p><a href="http://www.creativecommons.cn/licenses/by-nc-sa/1.0/" target="_blank"><img src="http://leaf.jdk.cn/rights.gif" border="0" height="31" alt="创造共用协议:署名,非商业,保持一致" width="88" /></a>   除经特别注明外,本文章版权归<strong><a href="http://jdkcn.com/" class=""><font color="#6b6b52">莫多泡泡</font></a></strong>所有. <br /><font color="#ff0000">署名,非商业用途,保持一致.</font>   <a href="http://jdkcn.com/" title="莫多泡泡" target="_blank">somebody(莫多)</a></p><img src="http://www.blogjava.net/rory/aggbug/87151.html" height="1" width="1" /><br /><br /><div align="right"><a href="http://www.blogjava.net/rory/" target="_blank" style="text-decoration:none;">莫多</a> 2006-12-12 10:33 <a href="http://www.blogjava.net/rory/archive/2006/12/12/tuckey-urlrewrite_3-querystring-problem.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/45872#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 12 Dec 2006 02:33:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/45872</link>
        <guid>http://somebody.javaeye.com/blog/45872</guid>
      </item>
      <item>
        <title>SpringXmlrpcServiceExporter for xmlrpc3.x</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/45873" style="color:red;">http://somebody.javaeye.com/blog/45873</a>&nbsp;
          发表时间: 2006年10月22日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>      我们的项目用到了xmlrpc,不过还是用的2.x版本的。由于xmlrpc3.x地推出。提供了NULL,Serializable等的支持，将原来的Hashtable改成了Map,Vector改成了List。都是不错的进步。所以我们决定从xmlrpc2.x升级到xmlrpc3.x.<br />      在spring里面有几个ServiceExporter，org.springframework.remoting.rmi.RmiServiceExporter、org.springframework.remoting.caucho.HessianServiceExporter、org.springframework.remoting.caucho.BurlapServiceExporter。不过没有xmlrpc的serviceExporter，原来我们是自己封装的XmlRpcServer,用servlet提供服务。(eg:http://localhost:8080/community/service/xmlrpc)没有和spring集成虽然用了spring。<br />    考虑到spring的便利以及配置的同意我决定将xmlrpcService放入spring中。xmlrpc3.x和xmlrpc2.x的代码基本上没有一样的。改了很多东西。除了类型变化之外，还添加了对异常的支持。详细信息请参照xmlrpc3.x源代码。<br />XmlRpcServiceExporter.java</p>
    <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
        <span style="COLOR: #0000ff">package</span>
        <span style="COLOR: #000000"> com.jdkcn.xmlrpc;<br /><br /></span>
        <span style="COLOR: #0000ff">import</span>
        <span style="COLOR: #000000"> javax.servlet.ServletException;<br /><br /></span>
        <span style="COLOR: #008000">/**</span>
        <span style="COLOR: #008000">
            <br /> * </span>
        <span style="COLOR: #808080">@author</span>
        <span style="COLOR: #008000"> &lt;a href="mailto:rory.cn@gmail.com"&gt;somebody&lt;/a&gt;<br /> * </span>
        <span style="COLOR: #808080">@since</span>
        <span style="COLOR: #008000"> 2006-9-27 03:59:22 pm<br /> * </span>
        <span style="COLOR: #808080">@version</span>
        <span style="COLOR: #008000"> $Id XmlRpcServiceExporter.java$<br /> </span>
        <span style="COLOR: #008000">*/</span>
        <span style="COLOR: #000000">
            <br />
        </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">class</span>
        <span style="COLOR: #000000"> XmlRpcServiceExporter </span>
        <span style="COLOR: #0000ff">extends</span>
        <span style="COLOR: #000000"> RemoteExporter </span>
        <span style="COLOR: #0000ff">implements</span>
        <span style="COLOR: #000000">
            <br />        Controller, InitializingBean {<br />    <br />    </span>
        <span style="COLOR: #0000ff">private</span>
        <span style="COLOR: #000000"> XmlRpcServletServer server;<br />    <br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> String serviceName;<br />    <br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> Resource configFile;<br />    <br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> Boolean enabledForExtensions;<br />    <br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">void</span>
        <span style="COLOR: #000000"> setEnabledForExtensions(Boolean enabledForExtensions) {<br />        </span>
        <span style="COLOR: #0000ff">this</span>
        <span style="COLOR: #000000">.enabledForExtensions </span>
        <span style="COLOR: #000000">=</span>
        <span style="COLOR: #000000"> enabledForExtensions;<br />    }<br /><br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">void</span>
        <span style="COLOR: #000000"> setConfigFile(Resource configFile) {<br />        </span>
        <span style="COLOR: #0000ff">this</span>
        <span style="COLOR: #000000">.configFile </span>
        <span style="COLOR: #000000">=</span>
        <span style="COLOR: #000000"> configFile;<br />    }<br /><br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> String getServiceName() {<br />        </span>
        <span style="COLOR: #0000ff">return</span>
        <span style="COLOR: #000000"> serviceName;<br />    }<br /><br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">void</span>
        <span style="COLOR: #000000"> setServiceName(String serviceName) {<br />        </span>
        <span style="COLOR: #0000ff">this</span>
        <span style="COLOR: #000000">.serviceName </span>
        <span style="COLOR: #000000">=</span>
        <span style="COLOR: #000000"> serviceName;<br />    }<br /><br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> XmlRpcServletServer getXmlRpcServletServer() {<br />        </span>
        <span style="COLOR: #0000ff">return</span>
        <span style="COLOR: #000000"> server;<br />    }<br />    <br />    </span>
        <span style="COLOR: #008000">/*</span>
        <span style="COLOR: #008000"> (non-Javadoc)<br />     * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)<br />     </span>
        <span style="COLOR: #008000">*/</span>
        <span style="COLOR: #000000">
            <br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> ModelAndView handleRequest(HttpServletRequest request,<br />            HttpServletResponse response) </span>
        <span style="COLOR: #0000ff">throws</span>
        <span style="COLOR: #000000"> Exception {<br />        </span>
        <span style="COLOR: #0000ff">if</span>
        <span style="COLOR: #000000"> (</span>
        <span style="COLOR: #000000">!</span>
        <span style="COLOR: #000000">WebContentGenerator.METHOD_POST.equals(request.getMethod())) {<br />            </span>
        <span style="COLOR: #0000ff">throw</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">new</span>
        <span style="COLOR: #000000"> ServletException(</span>
        <span style="COLOR: #000000">"</span>
        <span style="COLOR: #000000">XmlRpcServiceExporter only supports POST requests</span>
        <span style="COLOR: #000000">"</span>
        <span style="COLOR: #000000">);<br />        }<br />        server.execute(request, response);<br />        </span>
        <span style="COLOR: #0000ff">return</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">null</span>
        <span style="COLOR: #000000">;<br />    }<br /><br />    </span>
        <span style="COLOR: #008000">/*</span>
        <span style="COLOR: #008000"> (non-Javadoc)<br />     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()<br />     </span>
        <span style="COLOR: #008000">*/</span>
        <span style="COLOR: #000000">
            <br />    </span>
        <span style="COLOR: #0000ff">public</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">void</span>
        <span style="COLOR: #000000"> afterPropertiesSet() </span>
        <span style="COLOR: #0000ff">throws</span>
        <span style="COLOR: #000000"> Exception {<br />        server </span>
        <span style="COLOR: #000000">=</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">new</span>
        <span style="COLOR: #000000"> XmlRpcServletServer();<br />        server.setHandlerMapping(newXmlRpcHandlerMapping());<br />        </span>
        <span style="COLOR: #0000ff">if</span>
        <span style="COLOR: #000000"> (enabledForExtensions</span>
        <span style="COLOR: #000000">!=</span>
        <span style="COLOR: #0000ff">null</span>
        <span style="COLOR: #000000">) {<br />            ((XmlRpcServerConfigImpl) server.getConfig()).setEnabledForExtensions(enabledForExtensions.booleanValue());<br />        }<br />        <br />    }<br /><br />    </span>
        <span style="COLOR: #008000">/**</span>
        <span style="COLOR: #008000"> Creates a new handler mapping. The default implementation loads<br />     * a property file from the resource<br />     * <br />     </span>
        <span style="COLOR: #008000">*/</span>
        <span style="COLOR: #000000">
            <br />    </span>
        <span style="COLOR: #0000ff">protected</span>
        <span style="COLOR: #000000"> XmlRpcHandlerMapping newXmlRpcHandlerMapping() </span>
        <span style="COLOR: #0000ff">throws</span>
        <span style="COLOR: #000000"> XmlRpcException {<br />        <br />        SpringHandlerMapping mapping </span>
        <span style="COLOR: #000000">=</span>
        <span style="COLOR: #000000"> </span>
        <span style="COLOR: #0000ff">new</span>
        <span style="COLOR: #000000"> SpringHandlerMapping(getServiceInterface());<br />        mapping.addHandler(getServiceName(), getServiceInterface());<br />        mapping.setTagetObject(getProxyForService());<br />        </span>
        <span style="COLOR: #0000ff">return</span>
        <span style="COLOR: #000000"> mapping;<br />    }<br />    <br />}<br /></span>
    </div>
    <br />spring配置文件<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="accountService"</span><span style="COLOR: #ff0000">  class</span><span style="COLOR: #0000ff">="com.jdkcn.service.impl.AccountServiceImpl"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="rpcAccountService"</span><span style="COLOR: #ff0000"> class</span><span style="COLOR: #0000ff">="com.jdkcn.xmlrpc.XmlRpcServiceExporter"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="service"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">ref </span><span style="COLOR: #ff0000">bean</span><span style="COLOR: #0000ff">="accountService"</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="serviceName"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">jdkcn.accountService</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="enabledForExtensions"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">true</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="serviceInterface"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">com.jdkcn.service.AccountService</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">&gt;</span></div>然后映射一个地址就可以通过xmlrpc访问服务了<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="urlMapping"</span><span style="COLOR: #ff0000"> class</span><span style="COLOR: #0000ff">="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="mappings"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">props</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br />                </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">prop </span><span style="COLOR: #ff0000">key</span><span style="COLOR: #0000ff">="/account"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">rpcAccountService</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">prop</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">props</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">&gt;</span></div>web.xml<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">context-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">contextConfigLocation</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            classpath:spring/global.xml<br />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">context-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    <br />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">listener</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">listener-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">org.springframework.web.context.ContextLoaderListener</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">listener-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">listener</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">service</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">org.springframework.web.servlet.DispatcherServlet</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><br />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-mapping</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">service</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">/service/xmlrpc3/*</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-mapping</span><span style="COLOR: #0000ff">&gt;</span></div>然后我们的service地址就是这样的http://localhost:8080/service/xmlrpc3/account<br /><br />希望对大家有用，这里提供project下载。包含一个client程序。com.jdkcn.xmlrpc.Client<br /><br /><img src="http://jdkcn.com/images/download.gif" border="0" alt="" style="MARGIN: 0px 2px -4px 0px" /><a href="http://jdkcn.com/download.asp" title="点击下载完整代码" target="_blank">点击下载完整代码</a><br /><br /><a href="http://www.creativecommons.cn/licenses/by-nc-sa/1.0/" target="_blank"><img src="http://leaf.jdk.cn/rights.gif" border="0" height="31" alt="创造共用协议:署名,非商业,保持一致" width="88" /></a>   除经特别注明外,本文章版权归<strong><a href="http://jdkcn.com/" class=""><font color="#6b6b52">莫多泡泡</font></a></strong>所有. <br /><font color="#ff0000">署名,非商业用途,保持一致.</font>   <a href="http://jdkcn.com/" title="莫多泡泡" target="_blank">somebody(莫多)</a><img src="http://www.blogjava.net/rory/aggbug/76628.html" height="1" width="1" /><br /><br /><div align="right"><a href="http://www.blogjava.net/rory/" target="_blank" style="text-decoration:none;">莫多</a> 2006-10-22 16:12 <a href="http://www.blogjava.net/rory/archive/2006/10/22/spring_xmlrpc3_service_exporter.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/45873#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sun, 22 Oct 2006 08:12:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/45873</link>
        <guid>http://somebody.javaeye.com/blog/45873</guid>
      </item>
      <item>
        <title>关于Hibernate3的escape解决方法</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/45874" style="color:red;">http://somebody.javaeye.com/blog/45874</a>&nbsp;
          发表时间: 2006年10月16日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          不知道大家有没有碰到，还是没有这种需求。就是用like来查询，我们没有用Lucene,Compass这种全文索引的方案,我们只是简单的添加%进行like查询。用户搜索的时候就使用*和?来代表任意和一个。所以要对"%"和"_"进行转义，我们使用的是oracle数据库。sql语句看起来可能是这样的。<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000"> </span><span style="COLOR: #808080">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000"> t_user </span><span style="COLOR: #0000ff">where</span><span style="COLOR: #000000"> nickname </span><span style="COLOR: #808080">like</span><span style="COLOR: #000000"> </span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">%Goo\_D</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">escape</span><span style="COLOR: #000000"> </span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">\</span><span style="COLOR: #ff0000">'</span></div>这里对_进行转义了。因为用户昵称包含下划线，如果不进行转义就表示一个任意字符。有时候我们可能还需要对%进行转义。同样的方法在%前加\% 但是比起普通的like语句。多了一个声明转义符的语句。所以我们会想到这样的语句<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">DetachedCriteria criteria </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> DetachedCriteria.forClass(User.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);<br />criteria.add(Restrictions.like(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">nickname</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, user.getNickname()</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">' escape'\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));</span></div>但是这样是不管用的。<br />接下来可能会想到使用Hibernate3的原生sql查询，其实我们不需要这样做。我们还是使用Criteria条件查询。<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">criteria.add(Restrictions.sqlRestriction(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">{alias}.nickname like ? escape'/'</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, StringUtil.escapeSQLLike(user.getNickname()), Hibernate.STRING));</span></div>这样Hibernate产生的语句就是我们想要的语句了。<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * 转义like语句中的<br />     * &lt;code&gt;'_'&lt;/code&gt;&lt;code&gt;'%'&lt;/code&gt;<br />     * 将&lt;code&gt;'?'&lt;/code&gt;转成sql的&lt;code&gt;'/_'&lt;/code&gt;<br />     * 将&lt;code&gt;'%'&lt;/code&gt;转成sql的&lt;code&gt;'/%'&lt;/code&gt;<br />     * &lt;p&gt;<br />     *   例如搜索&lt;code&gt;?aa*bb?c_d%f&lt;/code&gt;将转化成&lt;br/&gt;<br />     *   &lt;code&gt;_aa%bb_c/_d/%f&lt;/code&gt;<br />     * &lt;/p&gt;<br />     * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> likeStr<br />     * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"><br />     * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> &lt;a href="</span><span style="COLOR: #008000; TEXT-DECORATION: underline">http://jdkcn.com</span><span style="COLOR: #008000">"&gt;somebody&lt;/a&gt;<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> String escapeSQLLike(String likeStr) {<br />        String str </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> StringUtils.replace(likeStr, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">_</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/_</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />        str </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> StringUtils.replace(str, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,    </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/%</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />        str </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> StringUtils.replace(str, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">_</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />        str </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> StringUtils.replace(str, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> str;<br />    }</span></div><br /><a href="http://www.creativecommons.cn/licenses/by-nc-sa/1.0/" target="_blank"><img src="http://leaf.jdk.cn/rights.gif" border="0" height="31" alt="创造共用协议:署名,非商业,保持一致" width="88" /></a>   除经特别注明外,本文章版权归<strong><a href="http://jdkcn.com/" class=""><font color="#6b6b52">莫多泡泡</font></a></strong>所有. <br /><font color="#ff0000">署名,非商业用途,保持一致.</font>   <a href="http://jdkcn.com" title="莫多泡泡" target="_blank">somebody(莫多)</a><img src="http://www.blogjava.net/rory/aggbug/75503.html" height="1" width="1" /><br /><br /><div align="right"><a href="http://www.blogjava.net/rory/" target="_blank" style="text-decoration:none;">莫多</a> 2006-10-16 23:29 <a href="http://www.blogjava.net/rory/archive/2006/10/16/hibernate3_escape.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>
          <br/>
          <span style="color:red;">
            <a href="http://somebody.javaeye.com/blog/45874#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 16 Oct 2006 15:29:00 +0800</pubDate>
        <link>http://somebody.javaeye.com/blog/45874</link>
        <guid>http://somebody.javaeye.com/blog/45874</guid>
      </item>
      <item>
        <title>关于spring启动的优化的问题</title>
        <author>somebody</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://somebody.javaeye.com">somebody</a>&nbsp;
          链接：<a href="http://somebody.javaeye.com/blog/27228" style="color:red;">http://somebody.javaeye.com/blog/27228</a>&nbsp;
          发表时间: 2006年08月10日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>  <span style="FONT-WEIGHT: bold">jspark</span> 的这篇文章《<a href="/jspark/archive/2006/07/29/60712.html" class="postTitle2" id="viewpost1_TitleUrl">开发阶段eclipse下面的spring容器的启动优化</a> 》讲到如何加快spring的启动速度。非常感谢<span style="FONT-WEIGHT: bold">jspark. </span>一下是引用的原文：<br /><br />  <span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">最近在负责一个大项目，项目组成员包括项目经理大概10个人左右。项目技术用struts+spring+hibernate实现。项目的规模相对来说是比较大的，总共有10大模块，每个大模块又分为有十几个、甚至几十个小模块。开发工具用eclipse，由于在开发阶段，项目开发成员需要频繁重启服务器。在启动服务器的时候，每次启动时间总是会超过1分钟。记得以前在做另外一个项目时，启动时间不到5秒钟，相差了10倍，而且项目规模是差不多的。</span><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">    从初步分析来说，应该是hibernate解释hbm.xml时花费时间，或者可能是spring容器启动并解释所有的bean配置文件。诊断了一下，发现1分钟消耗的时间主要分布在hibernate解释hbm.xml花费5秒；spring容器从启动到解释bean配置文件竟然花了58秒，真是太嚣张了。当时非常怀疑spring的效率问题。企图从网上搜索相关资料，看看有什么优化措施。</span><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">    首先是找到了hibernate的启动优化 </span><a href="http://www.hibernate.org/194.html" style="COLOR: rgb(51,51,153); FONT-STYLE: italic">http://www.hibernate.org/194.html</a><span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">  里面的主要思想是通过将xml序列花到本地的文件里，每次读取的时候根据情况，从本地文件读取并反序列化，节省了hibernate xml的解析时间。按照这个方式测试了一下，发现hibernate的启动时间从5秒降低到3秒，但是这个优化对于整个启动过程是杯水车薪的，毫无用处。</span><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">    没办法，又仔细查看了spring的资料，终于发现spring的容器是提供了lazy-load的，即默认的缺省设置是bean没有lazy- load，该属性处于false状态，这样导致spring在启动过程导致在启动时候，会默认加载整个对象实例图，从初始化ACTION配置、到 service配置到dao配置、乃至到数据库连接、事务等等。这么庞大的规模，难怪spring的启动时间要花将近1分钟。尝试了一下，把beans的 default-lazy-init改为true就，再次启动，速度从原来的55秒，降到8秒钟！！Great！虽然是非常小一个改动，但是影响确实非常大。一个项目组10个人，假若每个人一天平均需要在eclipse下启动测试服务器50次。那么一天项目组需要重启500次，每次节省50秒的话，就是 25000秒，将近几个小时，差不多一个工作日，多么可观的数字！</span><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">   不过在运行期间第一次点页面的时候，由于spring做了lazy-load，现在就需要启动一部分需要的beans，所以稍微慢2－3秒钟，但是明显比等几十秒要快很多，值得一鉴。</span><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><br style="COLOR: rgb(51,51,153); FONT-STYLE: italic" /><span style="COLOR: rgb(51,51,153); FONT-STYLE: italic">    以上是针对开发阶段的spring容器启动优化，在部署到实际环境中，倒是没必要设置为lazy-load。毕竟部署到实际环境中不是经常的事，每次启动1分钟倒不是大问题。 </span><br /><br />我这里要提醒的是不是说有的beans都能设置default-lazy-init成为true.对于scheduler的bean不能用lazy-init<br /><br /></p>
		<div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)">
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">beans </span>
				<span style="COLOR: rgb(255,0,0)">default-lazy-init</span>
				<span style="COLOR: rgb(0,0,255)">="true"</span>
				<span style="COLOR: rgb(0,0,255)">&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />    <br />    </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">bean </span>
				<span style="COLOR: rgb(255,0,0)">class</span>
				<span style="COLOR: rgb(0,0,255)">="org.springframework.scheduling.quartz.SchedulerFactoryBean"</span>
				<span style="COLOR: rgb(0,0,255)">&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />        </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">property </span>
				<span style="COLOR: rgb(255,0,0)">name</span>
				<span style="COLOR: rgb(0,0,255)">="triggers"</span>
				<span style="COLOR: rgb(0,0,255)">&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />            </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">list</span>
				<span style="COLOR: rgb(0,0,255)">&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />                </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">ref </span>
				<span style="COLOR: rgb(255,0,0)">bean</span>
				<span style="COLOR: rgb(0,0,255)">="buildHtmlTrigger"</span>
				<span style="COLOR: rgb(0,0,255)">/&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />                </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">ref </span>
				<span style="COLOR: rgb(255,0,0)">bean</span>
				<span style="COLOR: rgb(0,0,255)">="askTrigger"</span>
				<span style="COLOR: rgb(0,0,255)">/&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />                </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">ref </span>
				<span style="COLOR: rgb(255,0,0)">bean</span>
				<span style="COLOR: rgb(0,0,255)">="mailSenderTrigger"</span>
				<span style="COLOR: rgb(0,0,255)">/&gt;</span>
				<span style="COLOR: rgb(0,0,0)">
						<br />                </span>
				<span style="COLOR: rgb(0,0,255)">&lt;</span>
				<span style="COLOR: rgb(128,0,0)">ref </span>
				<span style="COLOR: rgb(255,0,0)">bean</span>
				<span style="COLOR: rgb(0,0,255)">="topicDetailBuildTrigger"</span