<?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>Neeke &#187; struts</title>
	<atom:link href="http://www.ineeke.com/tag/struts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ineeke.com</link>
	<description>悄悄记录点点滴滴</description>
	<lastBuildDate>Sat, 07 Jan 2012 13:04:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>3步配置Struts2</title>
		<link>http://www.ineeke.com/archives/869/</link>
		<comments>http://www.ineeke.com/archives/869/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 12:36:10 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[J2EE技术]]></category>
		<category><![CDATA[struts]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://ineeke.com/archives/3%e6%ad%a5%e9%85%8d%e7%bd%aestruts2/</guid>
		<description><![CDATA[<p>开始学习Struts2喽。Struts2与Strust1的配置方式几乎完全不同。先从struts.apache.org上下载了最新的struts2-2.1.6，由于目前还没有什么IDE支持Struts2，所以只能自己手工配置了。不过我也喜欢手工配置，什么东西都由工具来生成没有什么意思，脱离了工具就成白痴了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Struts bean:write filter" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F796%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts bean:write filter</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="什么是Struts" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F630%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">什么是Struts</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts DynaActionForm配置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F805%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts DynaActionForm配置</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts bean:write format" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F798%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts bean:write format</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="为什么使用Struts" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F628%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">为什么使用Struts</font>
                    </a>
                </td>
        </tr>
        <br/>
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">来自无觅网络的相关文章：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="普通、文艺、2B博主的区别" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.52playpc.com%2Fputong-wenyi-2b-blogger%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/11/07/10399729.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">普通、文艺、2B博主的区别 (@52playpc)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="RemoveWAT 2.2.6  Win7Crack.Tools" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fyusky.me%2Fsoftware%2Fremovewat-2-2-6-win7crack-tools.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/25/9479670.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">RemoveWAT 2.2.6  Win7Crack.Tools (@yusky)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IPAD2越狱知识总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.initers.com%2Fipad2-yueyu.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/08/05/21072120.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IPAD2越狱知识总结 (@initers)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="J2ME 游戏引擎 之 [学院惊变]程序框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fplumgo.cc%2Fj2me-game-engine-suddenschool-architecture%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/06/10/11689280.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">J2ME 游戏引擎 之 [学院惊变]程序框架 (@plumgo)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="libxml2 is missing error" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fyoumeiyou.info%2Farticles%2Ferror-libxml2-is-missing-error&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">libxml2 is missing error (@youmeiyou)</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" 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>开始学习Struts2喽。Struts2与Strust1的配置方式几乎完全不同。先从struts.apache.org上下载了最新的struts2-2.1.6，由于目前还没有什么IDE支持Struts2，所以只能自己手工配置了。不过我也喜欢手工配置，什么东西都由工具来生成没有什么意思，脱离了工具就成白痴了。</p>
<p>第一步，导包。下载下来的jar包并不是全都要，只需要下面这6个包即可。</p>
<p>1.commons-logging-1.0.4.jar</p>
<p>2.commons-fileupload-1.2.1.jar</p>
<p>3.freemarker-2.3.13.jar</p>
<p>4.ognl-2.6.11.jar</p>
<p>5.struts2-core-2.1.6.jar</p>
<p>6.xwork-2.1.2.jar</p>
<p>以上6个包，缺一不可。</p>
<p>第二步，修改web.xml。增加如下配置：</p>
<p>[xml]<br />
&lt;filter&gt;<br />
&lt;filter-name&gt;struts2&lt;/filter-name&gt;<br />
&lt;filter-class&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/filter-class&gt;<br />
&lt;/filter&gt;<br />
&lt;filter-mapping&gt;<br />
&lt;filter-name&gt;struts2&lt;/filter-name&gt;<br />
&lt;url-pattern&gt;/*&lt;/url-pattern&gt;<br />
&lt;/filter-mapping&gt;<br />
[/xml]</p>
<p>第三步，增加struts.xml文件。在struts1中，我们配置ActionForm及Action时是在strust-config.xml中，而在struts2中则是在struts.xml中，且该文件必须位于WEB-INF\classes目录下。</p>
<p>[xml]<br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;<br />
&lt;!DOCTYPE struts PUBLIC<br />
&quot;-//Apache Software Foundation//DTD Struts Configuration 2.1//EN&quot;<br />
&quot;http://struts.apache.org/dtds/struts-2.1.dtd&quot;&gt;<br />
&lt;struts&gt;<br />
&lt;package name=&quot;struts2&quot; extends=&quot;struts-default&quot;&gt;<br />
&lt;/package&gt;<br />
&lt;/struts&gt;<br />
[/xml]</p>
<p>经过上面这三步，Struts2就已经基本配置完成了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Struts bean:write filter" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F796%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts bean:write filter</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="什么是Struts" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F630%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">什么是Struts</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts DynaActionForm配置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F805%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts DynaActionForm配置</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts bean:write format" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F798%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts bean:write format</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="为什么使用Struts" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F628%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">为什么使用Struts</font>
                    </a>
                </td>
        </tr>
        <br/>
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">来自无觅网络的相关文章：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="普通、文艺、2B博主的区别" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.52playpc.com%2Fputong-wenyi-2b-blogger%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/11/07/10399729.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">普通、文艺、2B博主的区别 (@52playpc)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="RemoveWAT 2.2.6  Win7Crack.Tools" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fyusky.me%2Fsoftware%2Fremovewat-2-2-6-win7crack-tools.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/25/9479670.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">RemoveWAT 2.2.6  Win7Crack.Tools (@yusky)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="IPAD2越狱知识总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.initers.com%2Fipad2-yueyu.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/08/05/21072120.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">IPAD2越狱知识总结 (@initers)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="J2ME 游戏引擎 之 [学院惊变]程序框架" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fplumgo.cc%2Fj2me-game-engine-suddenschool-architecture%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/06/10/11689280.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">J2ME 游戏引擎 之 [学院惊变]程序框架 (@plumgo)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="libxml2 is missing error" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fyoumeiyou.info%2Farticles%2Ferror-libxml2-is-missing-error&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F869%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">libxml2 is missing error (@youmeiyou)</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" 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.ineeke.com/archives/869/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Struts+Spring+Hibernate集成</title>
		<link>http://www.ineeke.com/archives/851/</link>
		<comments>http://www.ineeke.com/archives/851/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 12:59:30 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[J2EE技术]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[struts]]></category>

		<guid isPermaLink="false">http://ineeke.com/archives/strutsspringhibernate%e9%9b%86%e6%88%90/</guid>
		<description><![CDATA[<p>SSH集成的一个样例，放到这里方便自己以后使用。其实就是一些配置，也没什么先后顺序。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Hibernate executeFind()" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1127%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8488354.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Hibernate executeFind()</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts+Hibernate+DisplayTag标签+js+Div+css系列教程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F658%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts+Hibernate+DisplayTag标签+js+Div+css系列教程</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring依赖注入" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F843%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring依赖注入</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC+Hibernate自动注入sessionFactory" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1262%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC+Hibernate自动注入sessionFactory</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1117%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" 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>SSH集成的一个样例，放到这里方便自己以后使用。其实就是一些配置，也没什么先后顺序。</p>
<p>web.xml增加</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contextConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>classpath*:applicationContext-*.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.web.context.ContextLoaderListener<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>修改Struts-config.xml中action的type属性为org.springframework.web.struts.DelegatingActionProxy</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE struts-config PUBLIC &quot;-//Apache Software Foundation//DTD Struts Configuration 1.3//EN&quot; &quot;http://struts.apache.org/dtds/struts-config_1_3.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;struts-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form-beans</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form-bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userForm&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cn.ineeke.ssh.web.form.UserForm&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form-beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;global-exceptions</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;global-forwards</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action-mappings</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span></span>
<span style="color: #009900;"><span style="color: #000066;">attribute</span>=<span style="color: #ff0000;">&quot;userForm&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;/index.jsp&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userForm&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">parameter</span>=<span style="color: #ff0000;">&quot;action&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/user&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">scope</span>=<span style="color: #ff0000;">&quot;request&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;org.springframework.web.struts.DelegatingActionProxy&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forward</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userlist&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/list.jsp&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forward</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;toUpdate&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/user_info.jsp&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action-mappings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;message-resources</span> <span style="color: #000066;">parameter</span>=<span style="color: #ff0000;">&quot;cn.ineeke.ssh.web.ApplicationResources&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/struts-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>对action进行注入，name属性必须与上面配置信息中action的path一致，class属性值为具体的action类。</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;/user&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;cn.ineeke.ssh.web.action.UserAction&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userBiz&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;userBiz&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>hibernate.cfg.xml的配置</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">'1.0'</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">'UTF-8'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE hibernate-configuration PUBLIC</span>
<span style="color: #00bbdd;">&quot;-//Hibernate/Hibernate Configuration DTD 3.0//EN&quot;</span>
<span style="color: #00bbdd;">&quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- Generated by MyEclipse Hibernate Tools.                   --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hibernate-configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;session-factory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connection.username&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>root<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connection.url&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
jdbc:mysql://localhost:3306/ssh
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dialect&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
org.hibernate.dialect.MySQLDialect
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;myeclipse.connection.profile&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>mysql<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connection.password&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>www.ineeke.com<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connection.driver_class&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
com.mysql.jdbc.Driver
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;show_sql&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mapping</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;cn/ineeke/ssh/entity/TUser.hbm.xml&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/session-factory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hibernate-configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>配置AOP</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:tx</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/tx&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:aop</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/aop&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans</span>
<span style="color: #009900;">http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</span>
<span style="color: #009900;">http://www.springframework.org/schema/tx</span>
<span style="color: #009900;">http://www.springframework.org/schema/tx/spring-tx-2.5.xsd</span>
<span style="color: #009900;">http://www.springframework.org/schema/aop</span>
<span style="color: #009900;">http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- 配置sessionFactory --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;sessionFactory&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;configLocation&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;classpath:hibernate.cfg.xml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- 配置事务管理器 --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;transactionManager&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.orm.hibernate3.HibernateTransactionManager&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sessionFactory&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;sessionFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- 配置事务的传播性 --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tx:advice</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;txAdvice&quot;</span> <span style="color: #000066;">transaction-manager</span>=<span style="color: #ff0000;">&quot;transactionManager&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tx:attributes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;add*&quot;</span> <span style="color: #000066;">propagation</span>=<span style="color: #ff0000;">&quot;REQUIRED&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;del*&quot;</span> <span style="color: #000066;">propagation</span>=<span style="color: #ff0000;">&quot;REQUIRED&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;modify*&quot;</span> <span style="color: #000066;">propagation</span>=<span style="color: #ff0000;">&quot;REQUIRED&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">read-only</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tx:attributes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tx:advice<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- 配置哪些类及其哪些方法参与该事务 --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;aop:config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;aop:pointcut</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;allMethod&quot;</span> <span style="color: #000066;">expression</span>=<span style="color: #ff0000;">&quot;execution(* cn.ineeke.ssh.biz.impl.*.*(..))&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;aop:advisor</span> <span style="color: #000066;">advice-ref</span>=<span style="color: #ff0000;">&quot;txAdvice&quot;</span> <span style="color: #000066;">pointcut-ref</span>=<span style="color: #ff0000;">&quot;allMethod&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/aop:config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Hibernate executeFind()" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1127%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8488354.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Hibernate executeFind()</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts+Hibernate+DisplayTag标签+js+Div+css系列教程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F658%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts+Hibernate+DisplayTag标签+js+Div+css系列教程</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring依赖注入" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F843%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring依赖注入</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC+Hibernate自动注入sessionFactory" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1262%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC+Hibernate自动注入sessionFactory</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1117%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" 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.ineeke.com/archives/851/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>疏忽下BeanUtils.copyProperties()引发的问题</title>
		<link>http://www.ineeke.com/archives/820/</link>
		<comments>http://www.ineeke.com/archives/820/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 17:12:45 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[J2EE技术]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[struts]]></category>

		<guid isPermaLink="false">http://ineeke.com/archives/%e7%96%8f%e5%bf%bd%e4%b8%8bbeanutilscopyproperties%e5%bc%95%e5%8f%91%e7%9a%84%e9%97%ae%e9%a2%98/</guid>
		<description><![CDATA[<p>昨天在Action中完成某一个更新功能的时候总是无法更新成功，而且什么错误都不报。经过仔细而又认真的再三查找，终于被我找到问题所在了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Struts+Spring+Hibernate集成" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts+Spring+Hibernate集成</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts+Hibernate+DisplayTag标签+js+Div+css系列教程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F658%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts+Hibernate+DisplayTag标签+js+Div+css系列教程</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Hibernate executeFind()" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1127%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8488354.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Hibernate executeFind()</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="为什么使用Struts" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F628%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">为什么使用Struts</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts DynaActionForm配置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F805%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts DynaActionForm配置</font>
                    </a>
                </td>
        </tr>
        <br/>
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">来自无觅网络的相关文章：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="海蜘蛛防火墙的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.dlxp.net%2Fhi-spider-common-problems.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/10/16/9239935.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">海蜘蛛防火墙的常见问题 (@dlxp)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Inno Setup教程－常见问题解答" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fyusky.me%2Fprogram%2Finno-setup-tutorial-faq.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/09/26/8077614.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Inno Setup教程－常见问题解答 (@yusky)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="解决了一个网站的大问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Finick.me%2Fhost-hongkang-china%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/07/20/18222407.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决了一个网站的大问题 (@inick)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="i8一点通相关问题及解决方法汇总！" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.dlxp.net%2F35.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/09/02/11694434.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">i8一点通相关问题及解决方法汇总！ (@dlxp)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于webView的中文乱码问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.getideas.cn%2F%3Fp%3D227&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于webView的中文乱码问题 (@getideas)</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" 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>昨天在Action中完成某一个更新功能的时候总是无法更新成功，而且什么错误都不报。经过仔细而又认真的再三查找，终于被我找到问题所在了。</p>
<p>先来说说查错过程。首先从更新失败与不报任何错误来看，我们的代码肯定是没有错的，错误应该是出在DAO层的SQL语句中。经查证，SQL语句也是正确的。给出SQL语句具体来看看。</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> sql <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE tb_member SET name=?,password=?,reallyName=?,age=?,profession=?,email=?,question=?,result=? WHERE id=? &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">boolean</span> ok <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
conn <span style="color: #339933;">=</span> DB.<span style="color: #006633;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt <span style="color: #339933;">=</span> conn.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">&#40;</span>sql<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, mbr.<span style="color: #006633;">getMbrName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span>, mbr.<span style="color: #006633;">getMbrPassword</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span>, mbr.<span style="color: #006633;">getMbrReallyName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span>, mbr.<span style="color: #006633;">getAge</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span>, mbr.<span style="color: #006633;">getMbrProfession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span>, mbr.<span style="color: #006633;">getMbrEmail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span>, mbr.<span style="color: #006633;">getMbrQuestion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span>, mbr.<span style="color: #006633;">getMbrResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pstmt.<span style="color: #006633;">setInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">9</span>, mbr.<span style="color: #006633;">getMbrId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> pstmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
ok <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>如上SQL语句，可以看到它是一个带更新条件的SQL语句（废话啊⊙﹏⊙b），那么在什么情况下这条语句可以正常执行而又返回的更新行数i又小于或等于0呢？答案就是，这里id的值在这张表中并不存在！</p>
<p>从上面的代码可以看到，这里的id是由pstmt.setInt(9, mbr.getMbrId())来赋值的。使用System.out.println(mbr.getMbrId())打印输出得到结果为0，其他属性值都存在。那就是说我们可能在Action中对mbr进行赋值时忘记了id属性。再检查一下Action中的方法。</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> ActionForward doUpdate<span style="color: #009900;">&#40;</span>ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span><span style="color: #009900;">&#123;</span>
MemberForm memberForm <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MemberForm<span style="color: #009900;">&#41;</span> form<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
HttpSession session <span style="color: #339933;">=</span> request.<span style="color: #006633;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> forwardName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;failure&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//获得当前会员信息</span>
<span style="color: #003399;">Member</span> mbr <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Member</span><span style="color: #009900;">&#41;</span>session.<span style="color: #006633;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;member&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//判断是否已经登录</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mbr <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//赋值</span>
BeanUtils.<span style="color: #006633;">copyProperties</span><span style="color: #009900;">&#40;</span>mbr, memberForm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//更新会员信息</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>mbrBiz.<span style="color: #006633;">updateMember</span><span style="color: #009900;">&#40;</span>mbr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
forwardName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;success&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">return</span> mapping.<span style="color: #006633;">findForward</span><span style="color: #009900;">&#40;</span>forwardName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>打眼一看好像也没错啊！起初我也认为绝对没错，我还以为是Tomcat的问题呢。后来仔细琢磨了一下BeanUtils.copyProperties(mbr, memberForm)这行代码。memberForm是前端控制器ActionServlet自动填充的，它封装了JSP页面中的表单数据。我使用BeanUtils.copyProperties()将memberForm中的各属性值逐一赋给mbr中的各个属性。这时我才突然明白了，我的JSP页面的表单中并不存在id这一数据！我将memberForm的id属性打印出来为null，由于BeanUtils.copyProperties()的内部实现机制的问题，这里它自动将mbr的id属性改为了0，于是就造成了更新不成功也不报错的结果。</p>
<p>那么，该怎么改好呢？很简单！在使用BeanUtils.copyProperties()方法之前先执行一下memberForm.setMbrId(mbr.getMbrId())即可。如此简单的一个问题花了我半个多小时，再加上分析整理写出来就更多了，O(∩_∩)O哈哈~。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Struts+Spring+Hibernate集成" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F851%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts+Spring+Hibernate集成</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts+Hibernate+DisplayTag标签+js+Div+css系列教程" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F658%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts+Hibernate+DisplayTag标签+js+Div+css系列教程</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Hibernate executeFind()" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1127%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8488354.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Hibernate executeFind()</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="为什么使用Struts" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F628%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">为什么使用Struts</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Struts DynaActionForm配置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F805%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Struts DynaActionForm配置</font>
                    </a>
                </td>
        </tr>
        <br/>
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">来自无觅网络的相关文章：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="海蜘蛛防火墙的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.dlxp.net%2Fhi-spider-common-problems.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/10/16/9239935.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">海蜘蛛防火墙的常见问题 (@dlxp)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Inno Setup教程－常见问题解答" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fyusky.me%2Fprogram%2Finno-setup-tutorial-faq.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/09/26/8077614.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Inno Setup教程－常见问题解答 (@yusky)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="解决了一个网站的大问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Finick.me%2Fhost-hongkang-china%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/07/20/18222407.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决了一个网站的大问题 (@inick)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="i8一点通相关问题及解决方法汇总！" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fblog.dlxp.net%2F35.html&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/09/02/11694434.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">i8一点通相关问题及解决方法汇总！ (@dlxp)</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="关于webView的中文乱码问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.getideas.cn%2F%3Fp%3D227&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F820%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">关于webView的中文乱码问题 (@getideas)</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" 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.ineeke.com/archives/820/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>log4j.properties配置文件</title>
		<link>http://www.ineeke.com/archives/809/</link>
		<comments>http://www.ineeke.com/archives/809/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 11:41:40 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[J2EE技术]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[log4j配置文件]]></category>
		<category><![CDATA[struts]]></category>

		<guid isPermaLink="false">http://ineeke.com/archives/log4jproperties%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6/</guid>
		<description><![CDATA[<p>在MyEclipse中配置好了Hibernate，运行的时候出现了两行红字，其意就是log4j没有配置，检查了一下发现果然没有配置。第一次用，哪会配置这东西啊！我以为这个MyEclipse也会自动生成呢！百度吧~</p>
]]></description>
			<content:encoded><![CDATA[<p>在MyEclipse中配置好了Hibernate，运行的时候出现了两行红字，其意就是log4j没有配置，检查了一下发现果然没有配置。第一次用，哪会配置这东西啊！我以为这个MyEclipse也会自动生成呢！百度吧~</p>
<p><span id="more-809"></span>
<p>#错误的级别是info级别 那么warm,error,fatal级别的信息都回输出</p>
<p>#另外有两个名字为CONSOLE和FILE的存放器</p>
<p>log4j.rootLogger=info,CONSOLE,FILE</p>
<p>#定义一个CONSOLE的存放器</p>
<p>log4j.addivity.org.apache=true</p>
<p>log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender</p>
<p>log4j.appender.Threshold=ERROR</p>
<p>log4j.appender.CONSOLE.Target=System.out</p>
<p>log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout</p>
<p>log4j.appender.CONSOLE.layout.ConversionPattern=[framework] %d &#8211; %c -%-4r [%t] %-5p %c %x &#8211; %m%n</p>
<p>#log4j.appender.CONSOLE.layout.ConversionPattern=[start]%d{DATE}[DATE]%n%p[PRIORITY]%n%x[NDC]%n%t[THREAD] n%c[CATEGORY]%n%m[MESSAGE]%n%n</p>
<p>#设置一个到文件的存放器,该文件可以追加</p>
<p>log4j.appender.FILE=org.apache.log4j.FileAppender</p>
<p>#文件名字</p>
<p>log4j.appender.FILE.File=file.log</p>
<p>#可以追加内容</p>
<p>log4j.appender.FILE.Append=true</p>
<p>log4j.appender.FILE.layout=org.apache.log4j.PatternLayout</p>
<p>log4j.appender.FILE.layout.ConversionPattern=[framework] %d &#8211; %c -%-4r [%t] %-5p %c %x &#8211; %m%n</p>
<p>log4j有三种主要的组件：</p>
<p>? \u00C8\u00D5\u00D6\u00BE\u00D0\u00C5\u00CF\u00A2\u00B5\u00C4\u00D3\u00C5\u00CF\u00C8\u00BC\u00B6\:\u00C8\u00D5\u00D6\u00BE\u00D0\u00C5\u00CF\u00A2\u00B5\u00C4\u00D3\u00C5\u00CF\u00C8\u00BC\u00B6\u00B4\u00D3\u00B8\u00DF\u00B5\u00BD\u00B5\u00CD\u00D3\u00D0FATAL\u00A1\u00A2 ERROR\u00A1\u00A2WARN\u00A1\u00A2INFO\u00A1\u00A2DEBUG\u00A3\u00AC\u00B7\u00D6\u00B1\u00F0\u00D3\u00C3\u00C0\u00B4\u00D6\u00B8\u00B6\u00A8\u00D5\u00E2\u00CC\u00F5\u00C8\u00D5\u00D6\u00BE\u00D0\u00C5\u00CF\u00A2\u00B5\u00C4\u00D6\u00D8\u00D2\u00AA\u00B3\u00CC\u00B6\u00C8</p>
<p>u debug\u00CF\u00B5\u00CD\u00B3\u00C1\u00F7\u00B3\u00CC\u00D6\u00D0\u00B5\u00C4\u00CF\u00B8\u00BD\u00DA\u00D0\u00C5\u00CF\u00A2</p>
<p>将以上配置信息保存为log4j.properties文件到你项目中的src目录下即可。如果不希望日志记录哪些信息，只要在其前面加上&ldquo;#&rdquo;即可。由于这个文件中日志的定义是可以自由配置的，所以上面的配置信息不一定是最全的。不过至少现在不会出现那几行红字了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/809/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Struts实现文件上传</title>
		<link>http://www.ineeke.com/archives/806/</link>
		<comments>http://www.ineeke.com/archives/806/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 07:32:02 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[J2EE技术]]></category>
		<category><![CDATA[java文件上传]]></category>
		<category><![CDATA[jsp实现文件上传]]></category>
		<category><![CDATA[struts]]></category>

		<guid isPermaLink="false">http://ineeke.com/archives/struts%e5%ae%9e%e7%8e%b0%e6%96%87%e4%bb%b6%e4%b8%8a%e4%bc%a0/</guid>
		<description><![CDATA[<p>客户端浏览器向WEB服务器上传文件是件比较复杂的事，之前我们有[<a target="_blank" href="../../../archives/372/">jsp实现文件上传</a>]和[<a target="_blank" href="../../../archives/ServletShiXianWenJianShangChuan/">Servlet中实现文件上传</a>] 这两种方式，我们发现那都需要写很多代码，而使用Struts为我们提供的文件上传机制就简单容易的多了。</p>
]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" src="http://www.ineeke.com/PLUGIN/Codelight/Jssc4/jssc4.js"></script></p>
<p>客户端浏览器向WEB服务器上传文件是件比较复杂的事，之前我们有[<a target="_blank" href="../../../archives/372/">jsp实现文件上传</a>]和[<a target="_blank" href="../../../archives/ServletShiXianWenJianShangChuan/">Servlet中实现文件上传</a>] 这两种方式，我们发现那都需要写很多代码，而使用Struts为我们提供的文件上传机制就简单容易的多了。</p>
<p><span id="more-806"></span>
<p>首先我们创建一个用于上传文件的JSP表单页。</p>
<pre class="html" style="border-right: rgb(204,204,204) thin ridge; border-top: rgb(204,204,204) thin ridge; border-left: rgb(204,204,204) thin ridge; border-bottom: rgb(204,204,204) thin ridge; background-color: rgb(240,240,240)" width="500" name="CodeLight_code" height="400">
&lt;%@ page language=&quot;java&quot; import=&quot;java.util.*&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Struts文件上传&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=&quot;upload.do&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
文件名：&lt;input type=&quot;text&quot; name=&quot;fileName&quot;&gt;&lt;br&gt;
文件：&lt;input type=&quot;file&quot; name=&quot;myfile&quot;&gt;&lt;br&gt;
&lt;input type=&quot;submit&quot;&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>注意一定要有enctype=&quot;multipart/form-data&quot;这个属性，否则无法上传的。</p>
<p>接着是ActionForm。</p>
<pre class="java" style="border-right: rgb(204,204,204) thin ridge; border-top: rgb(204,204,204) thin ridge; border-left: rgb(204,204,204) thin ridge; border-bottom: rgb(204,204,204) thin ridge; background-color: rgb(240,240,240)" width="500" name="CodeLight_code" height="400">
package cn.ineeke.fileupload.form;
import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;
/**
* 作用：测试学习Struts文件上传
* 作者：Neeke
* BLOG：http://www.ineeke.com
*/
public class UploadActionForm extends ActionForm {
private String fileName;
private FormFile myfile;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public FormFile getMyfile() {
return myfile;
}
public void setMyfile(FormFile myfile) {
this.myfile = myfile;
}
}
</pre>
<p>这里我们所上传的文件的类型必须使用FormFile！接下来就是Action了。</p>
<pre class="java" style="border-right: rgb(204,204,204) thin ridge; border-top: rgb(204,204,204) thin ridge; border-left: rgb(204,204,204) thin ridge; border-bottom: rgb(204,204,204) thin ridge; background-color: rgb(240,240,240)" width="500" name="CodeLight_code" height="400">
package cn.ineeke.fileupload.action;
import java.io.FileOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import cn.ineeke.fileupload.form.UploadActionForm;
/**
* 作用：测试学习Struts文件上传
* 作者：Neeke
* BLOG：http://www.ineeke.com
*/
public class UploadAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UploadActionForm upActForm = (UploadActionForm)form;
System.out.println(upActForm.getFileName());//打印出表单中所填写的文件名
FormFile formFile = upActForm.getMyfile();//获取FormFile
if(formFile != null){
System.out.println(formFile.getFileName());//打印出实际上传时所选文件的文件名
FileOutputStream fos = new FileOutputStream(&quot;c:\\&quot;+formFile.getFileName());//获取文件流对象
fos.write(formFile.getFileData());//开始写入
fos.flush();
fos.close();
}
return null;
}
}
</pre>
<p>具体的看旁边的注释应该就够了，万事俱备，只欠配置struts-config.xml了。</p>
<pre class="xml" style="border-right: rgb(204,204,204) thin ridge; border-top: rgb(204,204,204) thin ridge; border-left: rgb(204,204,204) thin ridge; border-bottom: rgb(204,204,204) thin ridge; background-color: rgb(240,240,240)" width="500" name="CodeLight_code" height="400">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE struts-config PUBLIC &quot;-//Apache Software Foundation//DTD Struts Configuration 1.3//EN&quot; &quot;http://struts.apache.org/dtds/struts-config_1_3.dtd&quot;&gt;
&lt;struts-config&gt;
&lt;form-beans&gt;
&lt;form-bean name=&quot;uploadActionForm&quot; type=&quot;cn.ineeke.fileupload.form.UploadActionForm&quot;&gt;&lt;/form-bean&gt;
&lt;/form-beans&gt;
&lt;global-exceptions /&gt;
&lt;global-forwards /&gt;
&lt;action-mappings&gt;
&lt;action path=&quot;/upload&quot;
type=&quot;cn.ineeke.fileupload.action.UploadAction&quot;
name=&quot;uploadActionForm&quot;
scope=&quot;request&quot;
&gt;
&lt;/action&gt;
&lt;/action-mappings&gt;
&lt;message-resources parameter=&quot;cn.ineeke.struts.ApplicationResources&quot; /&gt;
&lt;/struts-config&gt;
</pre>
<p>好了，所有的配置都结束了，可以正常上传文件了。不过，Struts默认的允许上传的文件最大为250M，如果我们只需要10M呢？怎么改？很简单！在struts-config.xml中&lt;/action-mappings&gt;标签后增加一句&lt;controller maxFileSize=&quot;10M&quot; /&gt;即可。</p>
<p><object id="jssc4" height="1" align="middle" width="1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="sameDomain" name="allowScriptAccess" /><param value="false" name="allowFullScreen" /><param value="http://www.ineeke.com/PLUGIN/Codelight/Jssc4/jssc4.swf" name="movie" /><param value="high" name="quality" /><param value="#ffffff" name="bgcolor" /><embed name="jssc4" height="1" align="middle" width="1" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#ffffff" quality="high" src="http://www.ineeke.com/PLUGIN/Codelight/Jssc4/jssc4.swf" allowscriptaccess="sameDomain" allowfullscreen="false"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/806/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

