<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>拈花微笑 &#187; struts</title>
	<atom:link href="http://www.jayxu.com/tags/struts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jayxu.com</link>
	<description>晶 · 彦</description>
	<lastBuildDate>Thu, 02 Feb 2012 09:24:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
<link>http://www.jayxu.com</link>
<url>http://www.jayxu.com/wp-content/cbnet-favicon/1289928181_Black_Cat.png</url>
<title>拈花微笑</title>
</image>
		<item>
		<title>使用Spring LDAP ODM操作LDAP</title>
		<link>http://www.jayxu.com/2011/12/14/13131/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e4%25bd%25bf%25e7%2594%25a8spring-ldap-odm%25e6%2593%258d%25e4%25bd%259cldap</link>
		<comments>http://www.jayxu.com/2011/12/14/13131/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 15:10:16 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring context]]></category>
		<category><![CDATA[spring ldap]]></category>
		<category><![CDATA[spring ldap odm]]></category>
		<category><![CDATA[spring mvc]]></category>
		<category><![CDATA[spring orm]]></category>
		<category><![CDATA[spring tx]]></category>
		<category><![CDATA[struts]]></category>
		<category><![CDATA[牢骚]]></category>

		<guid isPermaLink="false">http://www.jayxu.com/?p=13131</guid>
		<description><![CDATA[Spring Source真的是个很神奇的开源社区，从《J2EE without EJB》开始为大家所知晓，到把IoC、AOP大范围地带到大家的开发模型中，再到和Hibernate、Struts组成每个Java函授学校必教的“SSH”组合，从此绿遍大江南北…… 在国内，大马路上随便抓一个Java程序员，10个里有9个半知道Spring；有9个知道怎么把SSH“组装”到一起（是的，“组装”，和流水线上的蓝领熟练工没有本质区别）；有9个半知道IoC、AOP；有2个知道IoC和AOP的本质；有3个知道Spring其实分为core、context、orm、tx等不同子框架；有1个知道Spring 3之后可以用annotation取代之前版本大部分的xml配置；有2个知道Spring mvc和security；有半个知道其实Spring的子框架远不止这些……这就是我们当前Java码农们的实际情况。而造成这一局面的，我谓之三害——高校计算机系功利的培养模式、以北大青鸟为首的各种速成班的祸害和程序员们自己懒惰、人云亦云、拒绝思考的慢性自杀 牢骚发完，本文将通过介绍Spring的两个子框架：Spring LDAP和Spring LDAP ODM，来实现对LDAP的操作 项目主页：http://www.springsource.org/ldap，该框架通过提供和ORM中相似的机制对LDAP相关操作进行封装，主要包括： 类比SessionFactory的LdapContextSource 类比HibernateTemplate等的LdapTemplate 伪事务支持，能否与tx框架的TransactionManager混用未知 类比JPA的使用@Entry、@Attribute、@Id标注的ODM——Object Directory Mapping 本文（原先）目标：使用ODM将User类与LDAP中的实体进行映射，LDAP中的实体的objectClass包括inetOrgPerson，organizationalPerson，person，shadowAccount和top 相关配置文件、代码在http://static.springsource.org/spring-ldap/docs/1.3.x/reference/html/上已经很详细了，这里只是做一点旁注，全部来自于这几天和Spring LDAP的斗智斗勇 对于shadowAccount的shadowLastChange域，值是一个整形，至于具体含义网上没有找到解释，试了几次之后发现是从1970-1-1 00:00:00至今的天数，如果model里定义的是Date类型的话，需要自行实现org.springframework.ldap.odm.typeconversion.impl.Converter接口进行转换 对于@Entry标记，其中的objectClasses定义必须与objectClass完全一致。在新建和查询object时，ODM会根据此标记进行匹配，无需再指定objectClass 每个entry必须指定@Id字段，类型为javax.naming.Name，其实就是DN。但是若在LdapContextSource中指定了base，则DN将会按照base截取相对路径。比如，DN为cn=user,ou=users,dc=jayxu,dc=com，base为dc=jayxu,dc=com，则取出的user对象DN为cn=user,ou=users 如果使用Spring MVC对LDAP对象进行JSON序列化，必须注意javax.naming.Name中的某些字段无法被序列化，所以在转换成JSON之前需要将DN置null。一种方法是使用@JsonIgnoreProperties标记model类，比如：@JsonIgnoreProperties(“dn”) 对于不需要与LDAP进行映射的字段使用@Transient进行标记 考虑使用org.springframework.ldap.pool.factory.PoolingContextSource引入连接池 如果事务中需要与JDBC进行互操作，需要使用org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager作为tx manager 原创内容，转载请注明： 转载自拈花微笑 本文链接地址: 使用Spring LDAP ODM操作LDAP<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Apache给EJB 3.1（JSR #318）投了否决票</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>Spring Source真的是个很神奇的开源社区，从《J2EE without EJB》开始为大家所知晓，到把IoC、AOP大范围地带到大家的开发模型中，再到和Hibernate、Struts组成每个Java函授学校必教的“SSH”组合，从此绿遍大江南北……</p>
<p>在国内，大马路上随便抓一个Java程序员，10个里有9个半知道Spring；有9个知道怎么把SSH“组装”到一起（是的，“组装”，和流水线上的蓝领熟练工没有本质区别）；有9个半知道IoC、AOP；有2个知道IoC和AOP的本质；有3个知道Spring其实分为core、context、orm、tx等不同子框架；有1个知道Spring 3之后可以用annotation取代之前版本大部分的xml配置；有2个知道Spring mvc和security；有半个知道其实Spring的子框架远不止这些……这就是我们当前Java码农们的实际情况。而造成这一局面的，我谓之三害——高校计算机系功利的培养模式、以北大青鸟为首的各种速成班的祸害和程序员们自己懒惰、人云亦云、拒绝思考的慢性自杀</p>
<p>牢骚发完，本文将通过介绍Spring的两个子框架：Spring LDAP和Spring LDAP ODM，来实现对LDAP的操作</p>
<p>项目主页：<a href="http://www.springsource.org/ldap" target="_blank">http://www.springsource.org/ldap</a>，该框架通过提供和ORM中相似的机制对LDAP相关操作进行封装，主要包括：</p>
<ul>
<li>类比SessionFactory的LdapContextSource</li>
<li>类比HibernateTemplate等的LdapTemplate</li>
<li>伪事务支持，能否与tx框架的TransactionManager混用未知</li>
<li>类比JPA的使用@Entry、@Attribute、@Id标注的ODM——Object Directory Mapping</li>
</ul>
<p>本文（原先）目标：使用ODM将User类与LDAP中的实体进行映射，LDAP中的实体的objectClass包括inetOrgPerson，organizationalPerson，person，shadowAccount和top</p>
<p>相关配置文件、代码在<a href="http://static.springsource.org/spring-ldap/docs/1.3.x/reference/html/" target="_blank">http://static.springsource.org/spring-ldap/docs/1.3.x/reference/html/</a>上已经很详细了，这里只是做一点旁注，全部来自于这几天和Spring LDAP的斗智斗勇</p>
<ul>
<li>对于shadowAccount的shadowLastChange域，值是一个整形，至于具体含义网上没有找到解释，试了几次之后发现是从1970-1-1 00:00:00至今的天数，如果model里定义的是Date类型的话，需要自行实现org.springframework.ldap.odm.typeconversion.impl.Converter接口进行转换</li>
<li>对于@Entry标记，其中的objectClasses定义必须与objectClass完全一致。在新建和查询object时，ODM会根据此标记进行匹配，无需再指定objectClass</li>
<li>每个entry必须指定@Id字段，类型为javax.naming.Name，其实就是DN。但是若在LdapContextSource中指定了base，则DN将会按照base截取相对路径。比如，DN为cn=user,ou=users,dc=jayxu,dc=com，base为dc=jayxu,dc=com，则取出的user对象DN为cn=user,ou=users</li>
<li>如果使用Spring MVC对LDAP对象进行JSON序列化，必须注意javax.naming.Name中的某些字段无法被序列化，所以在转换成JSON之前需要将DN置null。一种方法是使用@JsonIgnoreProperties标记model类，比如：@JsonIgnoreProperties(“dn”)</li>
<li>对于不需要与LDAP进行映射的字段使用@Transient进行标记</li>
<li>考虑使用org.springframework.ldap.pool.factory.PoolingContextSource引入连接池</li>
<li>如果事务中需要与JDBC进行互操作，需要使用org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager作为tx manager</li>
</ul>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2011/12/14/13131/">使用Spring LDAP ODM操作LDAP</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&title=%E4%BD%BF%E7%94%A8Spring+LDAP+ODM%E6%93%8D%E4%BD%9CLDAP" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Apache给EJB 3.1（JSR #318）投了否决票</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2011/12/14/13131/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring之经验教训（一）</title>
		<link>http://www.jayxu.com/2010/07/18/2373/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spring%25e4%25b9%258b%25e7%25bb%258f%25e9%25aa%258c%25e6%2595%2599%25e8%25ae%25ad%25ef%25bc%2588%25e4%25b8%2580%25ef%25bc%2589</link>
		<comments>http://www.jayxu.com/2010/07/18/2373/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 17:27:24 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[struts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[依赖注入]]></category>

		<guid isPermaLink="false">http://jayxu.com/?p=2373</guid>
		<description><![CDATA[在现在的项目中我们使用了spring + hibernate + struts的架构，在享受aop, orm, ioc, di带来的种种便利的同时，我们亦遇到了很多莫名其妙或者说刻骨铭心的教训，今天先整理两点，日后继续补充 经验一：时刻牢记，spring、hibernate对对象 进行了动态代理，尽量不要试图在动态代理后的对象上进行反射，尤其是field！ 不管是hibernate的orm还是spring的声明式事务管理，都对原来的pojo、dao进行了动态代理。虽然s、h&#8220;号称&#8221;动态代理做得天衣无缝且无色无味，但是，那只是在&#8220;绝大多数情况下&#8221;，如果想对动态代理后的对象进行反射，麻烦便来了，代码片段： public static void setCreditInfoStatus&#40;CreditInfo info, CreditType type, CreditValidateStatus status&#41; &#123; &#160; &#160; ... &#160; &#160; &#160; Field&#91;&#93; fields = CreditInfo.class.getDeclaredFields&#40;&#41;; &#160; &#160; &#160; for &#40;Field f : fields&#41; &#123; &#160; &#160; &#160; &#160; if &#40;f.isAnnotationPresent&#40;Credit.class&#41; &#38;&#38; f.getAnnotation&#40;Credit.class&#41;.value&#40;&#41; == type&#41; &#123; &#160; &#160; &#160; &#160; <a href="http://www.jayxu.com/2010/07/18/2373/"> read more <span class="meta-nav">&#187;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F11%2F23%2F10275&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">如何在Hibernate中让SQLServer使用nvarchar代替varchar</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在现在的项目中我们使用了spring + hibernate + struts的架构，在享受aop, orm, ioc, di带来的种种便利的同时，我们亦遇到了很多莫名其妙或者说刻骨铭心的教训，今天先整理两点，日后继续补充</p>
<h4>经验一：时刻牢记，spring、hibernate对对象 进行了动态代理，尽量不要试图在动态代理后的对象上进行反射，尤其是field！</h4>
<p>不管是hibernate的orm还是spring的声明式事务管理，都对原来的pojo、dao进行了动态代理。虽然s、h&ldquo;号称&rdquo;动态代理做得天衣无缝且无色无味，但是，那只是在&ldquo;绝大多数情况下&rdquo;，如果想对动态代理后的对象进行反射，麻烦便来了，代码片段：</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="java"><ol><li class="li1"><div class="de1"><span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> setCreditInfoStatus<span class="br0">&#40;</span>CreditInfo info, CreditType type, CreditValidateStatus status<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw3">Field</span><span class="br0">&#91;</span><span class="br0">&#93;</span> fields <span class="sy0">=</span> CreditInfo.<span class="kw1">class</span>.<span class="me1">getDeclaredFields</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw3">Field</span> f <span class="sy0">:</span> fields<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>f.<span class="me1">isAnnotationPresent</span><span class="br0">&#40;</span>Credit.<span class="kw1">class</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> f.<span class="me1">getAnnotation</span><span class="br0">&#40;</span>Credit.<span class="kw1">class</span><span class="br0">&#41;</span>.<span class="me1">value</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">==</span> type<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">PropertyDescriptor</span> pd <span class="sy0">=</span> BeanUtils.<span class="me1">getPropertyDescriptor</span><span class="br0">&#40;</span>CreditInfo.<span class="kw1">class</span>, f.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>pd <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span> &nbsp;<span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">public static void setCreditInfoStatus(CreditInfo info, CreditType type, CreditValidateStatus status) {
    ...

    Field[] fields = CreditInfo.class.getDeclaredFields();

    for (Field f : fields) {
        if (f.isAnnotationPresent(Credit.class) &amp;&amp; f.getAnnotation(Credit.class).value() == type) {
            PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(CreditInfo.class, f.getName());
            if (pd != null)  {
                ...
            }
            break;
        }
    }
}</pre></div></div>

<p>原先第7行写为 info.getClass()，乍一看与现有的代码功能上是一样的，但是别忘了让人又恨又爱的动态代理！上面代码返回的是真正的CreditInfo class，而左边的返回的是动态代理后的class，即意味着，第一个&ldquo;if&rdquo;永远返回的是false，除非动态代理后的对象的field上附带了原有的annotation</p>
<h4>经验二：spring的声明式事务管理确很强大，强大到可以支持多线程，但是，结合上一点，不要在线程中调用this中的事务方法</h4>
<p>声明式事务，即spring中使用aop织入或 @Transactional标记的方法注入事务容器，码农们可以完全不用操心何时begin，何时commit，何时 rollback，有没有嵌套，绝对傻瓜级的编程模型。但是，牢记，spring中的aop、annotation都是使用动态代理实现的，即，如果没有经过动态代理便也没有了事务管理，代码片段：</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="java"><ol><li class="li1"><div class="de1"><span class="kw1">public</span> <span class="kw1">class</span> AutomatedService<span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="me1">loanQueue</span>.<span class="me1">execute</span><span class="br0">&#40;</span><span class="kw1">new</span> <span class="kw3">Runnable</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Thread</span> thread <span class="sy0">=</span> &nbsp;<span class="kw3">Thread</span>.<span class="me1">currentThread</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="sy0">!</span>thread.<span class="me1">isInterrupted</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loanService.<span class="me1">checkNSetLoanStatus</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Thread</span>.<span class="me1">sleep</span><span class="br0">&#40;</span>loanStatusCheckIntervalMinutes <span class="sy0">*</span> Consts.<span class="me1">ONE_MINUTE</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><span class="kw3">InterruptedException</span> ex<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thread.<span class="me1">interrupt</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">public class AutomatedService{
    ...

    loanQueue.execute(new Runnable() {

        @Override
        public void run() {
            Thread thread =  Thread.currentThread();

            while (!thread.isInterrupted()) {
                try {
                    loanService.checkNSetLoanStatus();

                    Thread.sleep(loanStatusCheckIntervalMinutes * Consts.ONE_MINUTE);
                } catch (InterruptedException ex) {
                    thread.interrupt();
                }
            }
        }
    });

    ...
}</pre></div></div>

<p>原先的checkNSetLoanStatus方法是定义在AutomatedService中的，且标记了@Transactional。 但是，令人发指的是，checkNSetLoanStatus中的事务没有被提交。在痛定思痛仔细回想了spring的声明式事务的本质后，豁然发现当调用this.checkNSetLoanStatus()时，并没有被织入事务管理。spring还没有霸道到或者说聪明到对this进行动态代理，于是将该方法移至其它service并注入，问题解决</p>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2010/07/18/2373/">Spring之经验教训（一）</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&title=Spring%E4%B9%8B%E7%BB%8F%E9%AA%8C%E6%95%99%E8%AE%AD%EF%BC%88%E4%B8%80%EF%BC%89" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F11%2F23%2F10275&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">如何在Hibernate中让SQLServer使用nvarchar代替varchar</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2010/07/18/2373/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>让Struts 2性能提升一个数量级的的5个步骤 [zz]</title>
		<link>http://www.jayxu.com/2009/01/06/1337/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e8%25ae%25a9struts-2%25e6%2580%25a7%25e8%2583%25bd%25e6%258f%2590%25e5%258d%2587%25e4%25b8%2580%25e4%25b8%25aa%25e6%2595%25b0%25e9%2587%258f%25e7%25ba%25a7%25e7%259a%2584%25e7%259a%25845%25e4%25b8%25aa%25e6%25ad%25a5%25e9%25aa%25a4</link>
		<comments>http://www.jayxu.com/2009/01/06/1337/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 02:55:48 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[转载]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[struts]]></category>
		<category><![CDATA[性能调优]]></category>

		<guid isPermaLink="false">http://ijay.net.cn/2009/01/06/1337/</guid>
		<description><![CDATA[原文：http://dev.yingzhitech.com/2009/01/06/96 freemarker 升级为2.3.14 ognl 升级为 2.7.3（要附加javassis类库） 根包下增加freemarker.properties文件，内容为template_update_delay=60000 struts.xml增加&#60;constant name=”struts.devMode” value=”false”/&#62;和&#60;constant name=”struts.freemarker.templatesCache” value=”true”/&#62; 把struts.xml中的默认拦截器定义为basicStack： &#60;package name=&#34;web&#34; extends=&#34;tiles-default&#34;&#62; &#160; &#160; &#60;default-interceptor-ref name=&#34;basicStack&#34; /&#62; &#60;/package&#62; &#60;package name="web" extends="tiles-default"&#62; &#60;default-interceptor-ref name="basicStack" /&#62; &#60;/package&#62; 执行了这几步之后，网站性能从5 req/s提升至70 req/s，请求处理时间从22s/req缩减至2s/req！ 参考连接： http://struts.apache.org/2.x/docs/performance-tuning.html http://www.blogjava.net/usherlight/archive/2008/07/01/211869.html http://www.blogjava.net/usherlight/archive/2008/07/12/214462.html http://www.blogjava.net/usherlight/archive/2008/09/02/226501.html 原创内容，转载请注明： 转载自拈花微笑 本文链接地址: 让Struts 2性能提升一个数量级的的5个步骤 [zz]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2008%2F11%2F25%2F1233%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">JFreeChart中的TimeSeries可能导致内存泄露</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F03%2F05%2F1441%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">慎用LinkedXxxx集合</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F11%2F11%2F1809%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">10 things all JAVA developers should know [zz]</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2005%2F11%2F07%2F171%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Java 销魂落魄散  [zz]</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>原文：<a href="http://dev.yingzhitech.com/2009/01/06/96" target="_blank">http://dev.yingzhitech.com/2009/01/06/96</a></p>
<ol>
<li>freemarker 升级为2.3.14</li>
<li>ognl 升级为 2.7.3（要附加javassis类库）</li>
<li>根包下增加freemarker.properties文件，内容为template_update_delay=60000</li>
<li>struts.xml增加&lt;constant name=”struts.devMode” value=”false”/&gt;和&lt;constant name=”struts.freemarker.templatesCache” value=”true”/&gt;</li>
<li>把struts.xml中的默认拦截器定义为basicStack：

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="xml"><ol><li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;package</span> <span class="re0">name</span>=<span class="st0">&quot;web&quot;</span> <span class="re0">extends</span>=<span class="st0">&quot;tiles-default&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;default-interceptor-ref</span> <span class="re0">name</span>=<span class="st0">&quot;basicStack&quot;</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;/package<span class="re2">&gt;</span></span></span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">&lt;package name="web" extends="tiles-default"&gt;
    &lt;default-interceptor-ref name="basicStack" /&gt;
&lt;/package&gt;</pre></div></div>

</li>
</ol>
<p>执行了这几步之后，网站性能从5 req/s提升至70 req/s，请求处理时间从22s/req缩减至2s/req！<br />
参考连接：<br />
<a href="http://struts.apache.org/2.x/docs/performance-tuning.html" target="_blank">http://struts.apache.org/2.x/docs/performance-tuning.html</a><br />
<a href="http://www.blogjava.net/usherlight/archive/2008/07/01/211869.html" target="_blank">http://www.blogjava.net/usherlight/archive/2008/07/01/211869.html</a><br />
<a href="http://www.blogjava.net/usherlight/archive/2008/07/12/214462.html" target="_blank">http://www.blogjava.net/usherlight/archive/2008/07/12/214462.html</a><br />
<a href="http://www.blogjava.net/usherlight/archive/2008/09/02/226501.html" target="_blank">http://www.blogjava.net/usherlight/archive/2008/09/02/226501.html</a><br />
<a href="http://struts.apache.org/2.x/docs/performance-tuning.html" target="_blank"></a>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2009/01/06/1337/">让Struts 2性能提升一个数量级的的5个步骤 [zz]</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F&title=%E8%AE%A9Struts+2%E6%80%A7%E8%83%BD%E6%8F%90%E5%8D%87%E4%B8%80%E4%B8%AA%E6%95%B0%E9%87%8F%E7%BA%A7%E7%9A%84%E7%9A%845%E4%B8%AA%E6%AD%A5%E9%AA%A4+%5Bzz%5D" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2008%2F11%2F25%2F1233%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">JFreeChart中的TimeSeries可能导致内存泄露</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F03%2F05%2F1441%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">慎用LinkedXxxx集合</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F11%2F11%2F1809%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">10 things all JAVA developers should know [zz]</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2005%2F11%2F07%2F171%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F01%2F06%2F1337%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Java 销魂落魄散  [zz]</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2009/01/06/1337/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

