﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Tin's Blog-随笔分类-Webwork相关</title><link>http://www.blogjava.net/iamtin/category/7425.html</link><description>You are coming a long way, baby~Thinking, feeling, memory...</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 11:55:38 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 11:55:38 GMT</pubDate><ttl>60</ttl><item><title>使用WebWork和Rome轻松暴露RSS</title><link>http://www.blogjava.net/iamtin/archive/2006/06/05/50596.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Mon, 05 Jun 2006 14:25:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/06/05/50596.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/50596.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/06/05/50596.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/50596.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/50596.html</trackback:ping><description><![CDATA[
		<p>WebWork的result实现非常实用，它很好的解决了View渲染的灵活性问题。这才是MVC模式的优势所在，而像JSF那样帮定JSP的MVC就吃不到这个甜头了。说WebWork2是Model 2 MVC的巅峰就在这些灵活的地方。<br />闲扯这个不是主要目的。现在Rome是Java下最常用的RSS包，最近消息似乎要转入Apache的Abdera合并变成更强大的聚合引擎。用Rome生成和解析RSS都很方便。今天讨论一下使用ROME给网站生成RSS，并通过WebWork2的Result机制渲染。<br />最初是从WebWork的Cookbook上看到的RomeResult的文章，一看就会，我这里其实不过是举个详细点的例子，注意我使用的是WebWork 2.2.2和Rome 0.8：<br /><a href="http://wiki.opensymphony.com/display/WW/RomeResult">http://wiki.opensymphony.com/display/WW/RomeResult</a><br />参考了和东的这篇Blog，利用rome写rss feed生成程序：<br /><a href="http://hedong.3322.org/newblog/archives/000051.html">http://hedong.3322.org/newblog/archives/000051.html</a></p>
		<p>首先创建RomeResult类：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br /> * <br /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">package</span>
				<span style="COLOR: #000000"> com.goldnet.framework.webwork.result;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.Writer;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> org.apache.log4j.Logger;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.opensymphony.webwork.ServletActionContext;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.opensymphony.xwork.ActionInvocation;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.opensymphony.xwork.Result;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndFeed;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.io.SyndFeedOutput;<br /><br /></span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br /> * A simple Result to output a Rome SyndFeed object into a newsfeed.<br /> * </span>
				<span style="COLOR: #808080">@author</span>
				<span style="COLOR: #008000"> Philip Luppens<br /> * <br /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> RomeResult </span>
				<span style="COLOR: #0000ff">implements</span>
				<span style="COLOR: #000000"> Result {<br /> </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">final</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">long</span>
				<span style="COLOR: #000000"> serialVersionUID </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">6089389751322858939L</span>
				<span style="COLOR: #000000">;<br /><br /> </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String feedName;<br /><br /> </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String feedType;<br /><br /> </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">final</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> Logger logger </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> Logger.getLogger(RomeResult.</span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">);<br /><br /> </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">
						<br />  * (non-Javadoc)<br />  * <br />  * @see com.opensymphony.xwork.Result#execute(com.opensymphony.xwork.ActionInvocation)<br />  </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br /> </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> execute(ActionInvocation ai) </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> Exception {<br />  </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (feedName </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">) {<br />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> ack, we need this to find the feed on the stack</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">   logger<br />     .error(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Required parameter 'feedName' not found. </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />       </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Make sure you have the param tag set and </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />       </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">the static-parameters interceptor enabled in your interceptor stack.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> no point in continuing ..</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000">;<br />  }<br /><br />  </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> don't forget to set the content to the correct mimetype</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">  ServletActionContext.getResponse().setContentType(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">text/xml</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />  </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> get the feed from the stack that can be found by the feedName</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">  SyndFeed feed </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> (SyndFeed) ai.getStack().findValue(feedName);<br /><br />  </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (logger.isDebugEnabled()) {<br />   logger.debug(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Found object on stack with name '</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> feedName </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">': </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />     </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> feed);<br />  }<br />  </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (feed </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">) {<br /><br />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (feedType </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">) {<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> Accepted types are: rss_0.90 - rss_2.0 and atom_0.3<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> There is a bug though in the rss 2.0 generator when it checks<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> for the type attribute in the description element. It's has a<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> big 'FIXME' next to it (v. 0.7beta).</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">    feed.setFeedType(feedType);<br />   }<br />   SyndFeedOutput output </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> SyndFeedOutput();<br />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">we'll need the writer since Rome doesn't support writing to an outputStream yet</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">   Writer out </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">;<br />   </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000"> {<br />    out </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> ServletActionContext.getResponse().getWriter();<br />    output.output(feed, out);<br />   } </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000"> (Exception e) {<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> Woops, couldn't write the feed ?</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">    logger.error(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Could not write the feed</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">, e);<br />   } </span>
				<span style="COLOR: #0000ff">finally</span>
				<span style="COLOR: #000000"> {<br />    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">close the output writer (will flush automatically)</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (out </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">) {<br />     out.close();<br />    }<br />   }<br /><br />  } </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> woops .. no object found on the stack with that name ?</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">   logger.error(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Did not find object on stack with name '</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> feedName<br />     </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">'</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />  }<br /> }<br /><br /> </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> setFeedName(String feedName) {<br />  </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.feedName </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> feedName;<br /> }<br /><br /> </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> setFeedType(String feedType) {<br />  </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.feedType </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> feedType;<br /> }<br /><br />}<br /></span>
		</div>
		<p>程序很简单。实现了Result接口，寻找一个与feedName参数匹配的SyndFeed实例，然后转换为指定的feedType类型，然后通过rome的SyndFeedOutput输出到Response去。<br />然后我们给我们的WebWork配置romeResult。<br />在xwork.xml中配置：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">package </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="default"</span>
				<span style="COLOR: #ff0000"> extends</span>
				<span style="COLOR: #0000ff">="webwork-default"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">result-types</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">result-type </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="feed"</span>
				<span style="COLOR: #ff0000"> class</span>
				<span style="COLOR: #0000ff">="com.goldnet.framework.webwork.result.RomeResult"</span>
				<span style="COLOR: #0000ff">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">result-types</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">interceptors</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> 然后是你的那些inteceptor配置等 </span>
				<span style="COLOR: #008000">--&gt;</span>
		</div>
		<p>这样我们就给xwork配置了一个叫做feed的result，它就是我们的romeResult。<br />然后我们实现一个类，来测试一下这个romeResult。<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br /> *<br /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">package</span>
				<span style="COLOR: #000000"> com.goldnet.webwork.action.news;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.opensymphony.xwork.ActionSupport;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndCategory;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndCategoryImpl;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndContent;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndContentImpl;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndEntry;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndEntryImpl;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndFeed;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> com.sun.syndication.feed.synd.SyndFeedImpl;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> org.apache.commons.logging.Log;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> org.apache.commons.logging.LogFactory;<br /><br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.util.ArrayList;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.util.Date;<br /></span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.util.List;<br /><br /><br /></span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br /> * </span>
				<span style="COLOR: #808080">@author</span>
				<span style="COLOR: #008000"> Tin<br /> *<br /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> TestFeedCreateAction </span>
				<span style="COLOR: #0000ff">extends</span>
				<span style="COLOR: #000000"> ActionSupport {<br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">final</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">long</span>
				<span style="COLOR: #000000"> serialVersionUID </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">2207516408313865979L</span>
				<span style="COLOR: #000000">;<br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">transient</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">final</span>
				<span style="COLOR: #000000"> Log log </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> LogFactory.getLog(TestFeedCreateAction.</span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">);<br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> maxEntryNumber </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">;<br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String siteUrl </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">http://127.0.0.1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> SyndFeed feed </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">;<br /><br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> TestFeedCreateAction() {<br />        </span>
				<span style="COLOR: #0000ff">super</span>
				<span style="COLOR: #000000">();<br />    }<br /><br />    @Override<br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> String execute() {<br />        List</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">News</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> newsList </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> getNewsList();<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (log.isDebugEnabled()) {<br />            log.debug(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Geting feed! and got news </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> newsList.size() </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">
						<br />                </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> pieces.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />        }<br /><br />        feed </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> SyndFeedImpl();<br /><br />        feed.setTitle(converttoISO(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">测试中的新闻系统</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">));<br />        feed.setDescription(converttoISO(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">测试中的新闻系统：测试Rome Result</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">));<br />        feed.setAuthor(converttoISO(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">测试Tin</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">));<br />        feed.setLink(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">http://www.justatest.cn</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><br />        List</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">SyndEntry</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> entries </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> ArrayList</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">SyndEntry</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">();<br />        feed.setEntries(entries);<br /><br />        </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (News news : newsList) {<br />            SyndEntry entry </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> SyndEntryImpl();<br />            entry.setAuthor(converttoISO(news.getAuthor()));<br /><br />            SyndCategory cat </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> SyndCategoryImpl();<br />            cat.setName(converttoISO(news.getCategory()));<br /><br />            List</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">SyndCategory</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> cats </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> ArrayList</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">SyndCategory</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">();<br />            cats.add(cat);<br />            entry.setCategories(cats);<br /><br />            SyndContent content </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> SyndContentImpl();<br />            content.setValue(converttoISO(news.getContent()));<br /><br />            List</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">SyndContent</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> contents </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> ArrayList</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">SyndContent</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">();<br />            contents.add(content);<br />            entry.setContents(contents);<br />            entry.setDescription(content);<br />            entry.setLink(siteUrl </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/common/news/displayNews.action?id=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">
						<br />                news.getId());<br />            entry.setTitle(converttoISO(news.getTitle()));<br />            entry.setPublishedDate(news.getPublishDate());<br />            entries.add(entry);<br />        }<br /><br />        </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> SUCCESS;<br />    }<br /><br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> String converttoISO(String s) {<br />        </span>
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000"> {<br />            </span>
				<span style="COLOR: #0000ff">byte</span>
				<span style="COLOR: #000000">[] abyte0 </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> s.getBytes(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">UTF-8</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><br />            </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> String(abyte0, </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">ISO-8859-1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />        } </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000"> (Exception exception) {<br />            </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> s;<br />        }<br />    }<br /><br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> List</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">News</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> getNewsList() {<br />        List</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">News</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> newsList </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> ArrayList</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">News</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">();<br /><br />        </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; i </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> maxEntryNumber; i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">) {<br />            News news </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> News();<br />            news.setTitle(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">测试标题</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000"> i);<br />            news.setContent(<br />                </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;p&gt;测试内容测试内容&lt;span style=\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">color:red\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;测试内容&lt;/span&gt;&lt;/p&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />            news.setPublishDate(</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> Date());<br />            news.setId(</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> Long(i));<br />            news.setAuthor(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Tin</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />            newsList.add(news);<br />        }<br /><br />        </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> newsList;<br />    }<br /><br />    </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />     * </span>
				<span style="COLOR: #808080">@return</span>
				<span style="COLOR: #008000"> Returns the maxEntryNumber.<br />     </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">long</span>
				<span style="COLOR: #000000"> getMaxEntryNumber() {<br />        </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> maxEntryNumber;<br />    }<br /><br />    </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />     * </span>
				<span style="COLOR: #808080">@param</span>
				<span style="COLOR: #008000"> maxEntryNumber The maxEntryNumber to set.<br />     </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> setMaxEntryNumber(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> maxEntryNumber) {<br />        </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.maxEntryNumber </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> maxEntryNumber;<br />    }<br /><br />    </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />     * </span>
				<span style="COLOR: #808080">@param</span>
				<span style="COLOR: #008000"> siteUrl The siteUrl to set.<br />     </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> setSiteUrl(String siteUrl) {<br />        </span>
				<span style="COLOR: #0000ff">this</span>
				<span style="COLOR: #000000">.siteUrl </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> siteUrl;<br />    }<br /><br />    </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />     * </span>
				<span style="COLOR: #808080">@return</span>
				<span style="COLOR: #008000"> Returns the feed.<br />     </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> SyndFeed getFeed() {<br />        </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> feed;<br />    }<br /><br />    </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> News {<br />        </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> Long id;<br />        </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String title;<br />        </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String content;<br />        </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> Date publishDate;<br />        </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String author;<br />        </span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000"> String category;<br /><br />        </span>
				<span style="COLOR: #008000">/**</span>
				<span style="COLOR: #008000">
						<br />  * Getter/Setter都省略了，使用了内部类，就是图个方便<br />  * 本意是模仿我们常常使用的Pojo，大家的实现都不一样，我突简单，里面其实可以有复杂类型的<br />  </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />    }<br />}<br /></span>
		</div>
		<p>真是不好意思，Getter/Setter占了大部分地方我省略去了。逻辑很简单，就是把我们的POJO影射到Feed的模型上面，过程很简单。我留下了几个参数可以在外面设置：<br />maxEntryNumber显示的feed的条数，链接生成时使用的SiteUrl，当然也可以通过request获取。<br />下面我们配置我们的Action，注意平时我们可能使用DAO生成newsList，而不是我这个写死的getNewsList()方法，此时可能需要配合Spring进行IOC的设置，我们这里省略掉。<br />下面是我们这个Action的xwork配置：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">package </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="news"</span>
				<span style="COLOR: #ff0000"> extends</span>
				<span style="COLOR: #0000ff">="default"</span>
				<span style="COLOR: #ff0000"> namespace</span>
				<span style="COLOR: #0000ff">="/news"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">action </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="feed"</span>
				<span style="COLOR: #ff0000"> class</span>
				<span style="COLOR: #0000ff">="com.goldnet.webwork.action.news.TestFeedCreateAction"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> 每次生成15条rss feed </span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="maxEntryNumber"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">15</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> 链接的前缀，我们使用Weblogic是7001，也许你的是8080 </span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="siteUrl"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">http://127.0.0.1:7001</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> result是feed </span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">result </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="success"</span>
				<span style="COLOR: #ff0000"> type</span>
				<span style="COLOR: #0000ff">="feed"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> feed名字是feed，对应我们这个Action中的那个SyndFeed的实例的名字feed，别忘记写getter </span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="feedName"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">feed</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> 制定生成的feed的类型，我这里选择rss_2.0 </span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #008000">&lt;!--</span>
				<span style="COLOR: #008000"> rome 0.8支持atom_0.3、atom_1.0、rss_1.0、rss_2.0、rss_0.90、rss_0.91、rss_0.91、rss_0.91U、rss_0.92、rss_0.93、rss_0.94 </span>
				<span style="COLOR: #008000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param </span>
				<span style="COLOR: #ff0000">name</span>
				<span style="COLOR: #0000ff">="feedType"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">rss_2.0</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">result</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">action</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">package</span>
				<span style="COLOR: #0000ff">&gt;</span>
		</div>
		<p>OK，配置完毕后访问/news/feed.action就可以访问到这个feed了。倒入你的feedDeamon，看看，是不是非常简单？<br />不过需要考虑两个地方，一个是编码问题，看了和东说的中文问题，本没当回事，结果生成乱码（我们项目全部使用UTF-8），然后还是转了一下。没有研究ROME源代码，感觉xml不应该有UTF-8还会乱码的问题呀，也许还需要看看是否是设置不到位。还有就是对于feed如果增加了权限认证则访问比较麻烦，用feedDeamon这样的客户端就无法访问到了，因为它不会显示登陆失败后显示的登陆页面，也许放feed就要开放一点吧（当然还是有变通放案的）。<br />和动例子里面的rome 0.7和现在的rome 0.8相比，Api已经发生了不少变化，唉，开源要代码稳定还真难。<br />就这些，就到这里，粗陋了:D</p>
<img src ="http://www.blogjava.net/iamtin/aggbug/50596.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-06-05 22:25 <a href="http://www.blogjava.net/iamtin/archive/2006/06/05/50596.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WebWork 2.2.2中文上传乱码问题[临时解决方案] </title><link>http://www.blogjava.net/iamtin/archive/2006/03/30/38365.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Thu, 30 Mar 2006 13:40:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/03/30/38365.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/38365.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/03/30/38365.html#Feedback</comments><slash:comments>10</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/38365.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/38365.html</trackback:ping><description><![CDATA[
		<span class="postbody">使用jakarta commons-upload。 <br />升级到2.2.2后发现上传中文会乱码。 <br />经过跟踪发现在com.opensymphony.webwork.dispatcher.DispatcherUtils的prepare(HttpServletRequest request, HttpServletResponse response)方法。 <br />2.2.1-&gt;2.2.2时这个方法发生了非常的的变化。 <br />2.2.1时： <br /><span class="postbody"><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> prepare(HttpServletRequest request, HttpServletResponse response) { <br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (encoding </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) { <br />            </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> { <br />                request.setCharacterEncoding(encoding); <br />            } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (Exception e) { <br />                LOG.error(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Error setting character encoding to '</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> encoding </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">' - ignoring.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, e); <br />            } <br />        } <br /><br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (locale </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) { <br />            response.setLocale(locale); <br />        } <br /><br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (paramsWorkaroundEnabled) { <br />            request.getParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">foo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> simply read any parameter (existing or not) to "prime" the request </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">        } <br />    }</span></div></span></span>
		<span class="postbody">
				<br />2.2.2时： <br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> prepare(HttpServletRequest request, HttpServletResponse response) { <br />        String encoding </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">; <br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (Configuration.isSet(WebWorkConstants.WEBWORK_I18N_ENCODING)) { <br />            encoding </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Configuration.getString(WebWorkConstants.WEBWORK_I18N_ENCODING); <br />        } <br /><br />        Locale locale </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">; <br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (Configuration.isSet(WebWorkConstants.WEBWORK_LOCALE)) { <br />            locale </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> LocalizedTextUtil.localeFromString(Configuration.getString(WebWorkConstants.WEBWORK_LOCALE), request.getLocale()); <br />        } <br /><br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (encoding </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">MultiPartRequest.isMultiPart(request)) { <br />            </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> { <br />                request.setCharacterEncoding(encoding); <br />            } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (Exception e) { <br />                LOG.error(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Error setting character encoding to '</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> encoding </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">' - ignoring.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, e); <br />            } <br />        } <br /><br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (locale </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) { <br />            response.setLocale(locale); <br />        } <br /><br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (paramsWorkaroundEnabled) { <br />            request.getParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">foo</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> simply read any parameter (existing or not) to "prime" the request </span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">        } <br />    }</span></div></span>
		<span class="postbody">
				<br />
				<br />我看了jira没有发现encoding != null &amp;&amp; !MultiPartRequest.isMultiPart(request)这个判断的意义。但是它会造成对multiPartRequest的encoding判断失败，中文就会乱码。 <br />所以临时的解决方案是将判断改成： <br />if (encoding != null) <br /><br />听说WW的Jira已经不接受新issue了，不知是否真的？ <img alt="Crying or Very sad" src="http://forum.javaeye.com/images/smiles/icon_cry.gif" border="0" /></span>
		<span class="postbody">
		</span>
		<span class="gensmall">
		</span>
<img src ="http://www.blogjava.net/iamtin/aggbug/38365.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-03-30 21:40 <a href="http://www.blogjava.net/iamtin/archive/2006/03/30/38365.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java Web 框架的“甜点”</title><link>http://www.blogjava.net/iamtin/archive/2006/03/30/WebFrameworkSweetSpots.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Thu, 30 Mar 2006 08:28:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/03/30/WebFrameworkSweetSpots.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/38276.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/03/30/WebFrameworkSweetSpots.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/38276.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/38276.html</trackback:ping><description><![CDATA[
		<p>
				<font size="6">
						<strong>Jave Web Framework Sweet Spots</strong>
				</font>
				<br />
				<font size="5">
						<strong>Java Web 框架的“甜点”</strong>
				</font>
		</p>
		<p>这是一篇很有趣的文档，所以摘要一下，其实类似阅读笔记，好像是3/25发布的：</p>
		<p>不知怎么翻译Sweet Spots，难道翻译为甜处、甜头、蜜点、蜜穴？</p>
		<p>这时基于对以下人的采访：<br />JSF  Jacob Hookom<br />RIFE  Geert Bevin<br />Seam  Gavin King<br />Spring MVC Rob Harrop<br />Spring Web Flow Rob Harrop and Keith Donald<br />Stripes  Tim Fennell<br />Struts Action 1 Don Brown<br />Tapestry Howard Lewis Ship<br />Trails  Chris Nelson<br />WebWork  Patrick Lightbody<br />Wicket  Eelco Hillenius</p>
		<p>原文在此：<a href="http://www.virtuas.com/articles/webframework-sweetspots.html">http://www.virtuas.com/articles/webframework-sweetspots.html</a></p>
		<p>
				<font size="6">
						<strong>
								<font size="5">JSF(Jacob Hookom)</font>
								<br />
						</strong>
				</font>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？<br />当你希望浏览器程序像桌面程序一样工作的时候，你可以遵循标准并获得大量第三方支持。它致力于降低复杂度。它允许你不与view和特定的action、参数传递、状态传递、渲染打交道就可以进行高质量的开发，不管是否使用工具。<br />2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？<br />它不适合大规模的、只读（其实指读为主）的网站。在这种情况推荐Struts，因为知识库丰富（应该指文档和用户群）。<br />3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？<br />Seam：<br />优点：非常简单直接<br />缺点：对于大项目过于简单；没有模块化开发的好例子<br />Struts：<br />优点：巨大的文档和用户群；跟着它没错<br />缺点：状态/行为的分离过于教条化<br />WebWork：<br />优点：比Struts易于使用<br />缺点：复杂的UI难于维护，UI代码过于复杂（JSF作者对action Framework都攻击这一点）<br />Tapestry：<br />优点：概念新颖；可以应付复杂的UI<br />缺点：对于一个组件化（JSF主要竞争对手），它依然依附于page/action的概念<br />4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？<br />他认为JSF这个标准下这些应该有第三方提供。JSF(2.0)会提供“Partial Faces Request”，它是Ajax实现。JSF也会增强annotation组建编程。<br />5、有对你们的framework的传言需要澄清么？如果有，是哪个？<br />很多JSF书都拿Struts作为对比。他认为这不能体现JSF的特点。他认为Struts和WebWork能做到的JSF也能做到。<br />6、你对Ruby on Rails的看法如何？<br />它与WebWork一样好用，它的CoC（Convention over Configration）和脚手架非常好用。他认为CoC可以被应用在任何framework，他认为这是RoR最大的优点。他还认为RoR会走上其它framework的路（复杂性等），因为人们需要自己的扩展。</p>
		<p>
				<font size="5">
						<strong>RIFE(Geert Bevin)</strong>
						<br />
				</font>
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />你可以付出10%的工作量，得到其它framework的90%的……，它是一个full-stack framework（如RoR）。它吸收了成熟的分层框架的架构，并将共同的优点汇集在一起。提供了web continuation，POJO驱动的CRUD生成，可扩展的基于组建的架构，无session的状态控制，关注REST作为API，双向无逻辑模版引擎，集成了内容控制框架（CMS？）。每个层次的组建提供了可复用性（AOP，site，sub-site，page，widget，portlet等）。适合于团队快速开发公共Web项目，适合喜欢开发可复用组件的人。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />团队中的每个人都有其它framework的知识，难于培训他们。开发状态相关的服务器端Web组件，而不是用RIA或Ajax去实现。第三方支持很重要的情况下（可怜RIFE用户群还不大）。他推荐这种情况下使用JSF。或者在XML为主要发布形式的情况下，推荐Cocoon。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />他试验过WebWork，JSF，Wicket。他喜欢WebWork的简单，但是不喜欢它的模版方式（tag的template，应该），它也不提供组件封装。他认为JSF的工具支持非常吸引人。Wicket的纯Java实现很不错，可惜XML配置很不爽。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />关于Ajax，RIFE刚刚集成了DWR，而且选定以后也使用这个。集成Dojo，Scriptaculous，Prototype都很容易集成进来。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />这些错误理念：1、RIFE的XML配置繁琐 2、RIFE是continuations server 3、RIFE重新造轮子没有提供新鲜东西 4、RIFE的模版语法很蹩脚过于简单和业余 5、RIFE是基于request的framework 6、RIFE的功能太多，学习曲线陡峭<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />RoR对Java社区的冲击非常棒，元编成也得到了信任。RoR没什么特殊之处，也没有从Ruby语言获益很多。<br />我讨厌：它的模版。Partials（RoR中的组件）。URL的分散处理。Active Record提供了从数据库schema而来的DSL，但是却不是从domain model而来。没有l10n和i18n支持。手动状态转换。不能在JVM运行（……）。实际上脚手架生成了实际代码。Ruby缺少工具和IDE。</p>
		<p>
				<strong>
						<font size="6">
								<font size="5">Seam(Gavin King)</font>
								<br />
						</font>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />拥有丰富用户交互体验的应用。方便实现多窗口的操作，回退的支持，单窗口多工作区，无状态浏览。对商务流程（BPM）的集成是独一无二的。Seam方便使用数据驱动的ORM。遵循JSF和EJB3，多任务支持（多窗口/多工作区），BPM的领先解决方案。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />不适合只是将数据从数据库显示到网页的应用，这时应该使用PHP或RoR。不适合需要设计特别的HTML组件的情况，此时应该选用Tapestry或Wicket。还在使用JDK1.4的人们。还有那些喜欢Struts的人（嘿嘿，够狠）。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />JSF：喜欢他的事件/交互模型。喜欢他的EL和模型绑定。不喜欢那么多XML（为什么没有annotation）。创建自己的controls太难了。<br />Tapestry：非常好。form验证是它的杀手锏！模版方式很有创意。不过非基于POJO的组件模型则让我对它失去兴趣。<br />RIFE：这个东西很怪，但是有创业也有趣。我想进一步学习。如果学习先要自费武功:D<br />Struts：这个东西的模型view绑定太复杂了。东西已经过时了。<br />WebWork：比Struts好一点，不过也过时了。XWork曾经是个很好的实现，不过现在也过时了。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />Portal支持。远程框架Seam Remoting Framework（Ajax）。模版消息的工具支持。以后还要集成ESB，计划引擎和异步支持。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />这些都不是真的：JSF不能处理GET requests。JSF post后无法redirect。JSF不能与REST共存。<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />它是PHP的很好替代品。如果它有一个正经一点的持久化层它就可以和Java竞争了。</p>
		<p>
				<font size="6">
						<strong>
								<font size="5">Spring MVC(Rob Harrop)和Spring Web Flow(Rob Harrop and Keith Donald)</font>
						</strong>
				</font>
				<br />
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />Spring MVC：<br />稳定可扩展，支持了i18n、文件上传、异常处理，这些稳定的支持给开发者坚实的工作基础。是最佳实践，告诉你怎么做是最好的。与Spring集成，领先的IoC远生支持。支持，Spring社区活跃和庞大。Struts开发者可以平滑过渡。适合多种项目，可选的多种result类型。<br />Spring Web Flow：<br />内置任务处理引擎，支持线性处理过程中的持续状态。抽象，减少开发的关注点。适合多种项目类型，插件支持Spring MVC、Struts、JSF等。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />Spring MVC：不适合需要组件化开发的场景。它是一个request驱动的MVC。那些场景推荐JSF或Tapestry。<br />Spring Web Flow：处理线性页面流，不适合一般的“自由浏览”。当然Spring Web Flow可以与request驱动或者组件驱动共存。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />Spring框架支持Struts和JSF集成。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />Spring MVC：简化JSP标签。更多的MVC配置schema。CoC风格的默认控制器、URL影射、view，学习Rails和Stripes的优点。增强数据绑定和验证（支持范型绑定）。Portlet支持。Spring也要接受Ajax，使用DWR库。<br />Spring Web Flow：一大堆，关心的可以自己看……<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />Spring MVC难于配置。在Spring 2.0，将会改善，可以使用自己定义的基于schema的配置。<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />Spring MVC：RoR非常有趣。不过现在就拿出来用还有点幼稚。这里举了个例子，关于变量的复数形式的处理，RoR会使用这样的CoC风格来处理变量list，而Spring MVC也实验了种种风格，但是受到的结果却很差。人们认为英语的复数很古怪，没有一定的规则，所以会带来混乱，如（person -&gt; people）。所以Spring MVC设计了变量+List的命名，personList更加明确，虽然这样不酷，但更好用。就是说Spring MVC要取其精华去其糟粕。</p>
		<p>
				<font size="6">
						<strong>
								<font size="5">Stripes(Tim Fennell)</font>
						</strong>
				</font>
				<br />
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />与Spring MVC、WebWork等相同。它提供高质量action驱动的框架的同时，尽量简化配置，增进开发效率。Stripes适合复杂的数据交互的场合。这种情况下绑定验证的强项就完全体现出来了，能够很好的处理form和map转换等。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />所有的action驱动的framework都适合用户在非Ajax驱动的情况下在一个页面进行松关联（loosely related）和无状态交互的情况。适合每次都刷新的页面。管理多窗口间持续状态的应用会比较麻烦，此时应该选择JSF。不过我认为90%以上的Web程序都是前者，JSF只适合剩下的那9%，AJAX对于管理无状态UI更加适合。客户端不需要AJAX，则可以看看Wicket，它更加简单。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />用过Struts、WebWork、Spring MVC。其中Struts做过商业项目，不过这个东西带来的麻烦远比带来的效率提升要多。它认为这些MVC都有三个缺点：暴露了过多的复杂性给可发者。没有提供足够的开发便利性，没有提供足够多的错误和提示信息，也没有date格式化等小的便利（其实有）。稳当太差。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />1.3要加入Inteceptor，实现AOP功能。验证系统要加强。支持Ajax。我还在寻找一个好的Ajax/javascript库。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />这些观点：1、Stripes使用了annotation代替XML，只是换汤不换药：由于元数据更接近代码，所以修改默认的配置非常方便，不像XML那样复杂，这是实质的变化。2、Annotation意味着你只能有一套配置：我认为90%的action都有自己的一套配置！Stripes会根据继承关系寻找Annotations，子类的annotation会覆盖父类的，因为像validation都是可以继承的，如果特别需要还可以覆盖。这样很合理。在1.3中允许validations基于UI事件进行。它向后兼容，不需要可以不用。<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />我认为Java社区有很多可以从RoR学习的地方。Stripes学习了RoR的前端部分，开发者可以减少配置量。但是RoR的RHTML让我想到了以前的JSP中混乱的scriptlet。而后面的ActiveRecord是一个很好的理念，实现的也很好。ActiveRecord比Hibernate等复杂的ORM工具要容易理解，因为这样的特点RoR才引起了这么大的波澜。</p>
		<p>
				<font size="5">
						<strong>Struts Action 1(Don Brown)</strong>
						<br />
				</font>
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />文档和用户基础，书籍和背后的支持。容易雇到人（也容易找工作）。虽然其他项目的理念比这个要先进，但是这些不算什么。实际上，Web层是很容易也很直接的。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />如果你需要portlets或者复杂的页面（显示很多东西），那么Struts要么无法工作要么太枯燥。这种情况你需要一个基于组件的framework，如JSF、Tapestry/Wicket。<br />3<strong>、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />这些我基本都试验过，他们每个都工作的很不错。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />Struts Action 2基于WebWork2，很快会开始。现在已经支持Ajax了，我们在寻找更加容易的开发方式，JSF支持（Struts Shale），continuation支持，还有支持更多的脚本语言（BSF扩展脚本撰写Action）。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />Struts太过时了，而且也不酷，难于使用。但是你可以自己修改或者扩展它。我认为团队对于你的限制远大于framework对你的限制。<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />不需要D&amp;D工具，旨在帮助开发人员提高开发效率的好例子。我们在Action 2中将学习它的先进理念。</p>
		<p>
				<font size="6">
						<strong>
								<font size="5">Tapestry(Howard Lewis Ship)</font>
						</strong>
				</font>
				<br />
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />我想Tapestry对于中等规模或者大规模的应用会带来很多好处（甚至你可以在单页面的应用程序中获得好处）。这里有允许你创建新的组件的良好工具。Tapestry不关心数据从哪里来，很多“项目类型”都基于切面（aspect）（如CRUD vs. RSS feed vs. etc.）。我认为Tapestry非常容易与IoC集成（HiveMind或与Spring），方便进行测试。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />我在其它Java framework中没有找到到强于Tapestry的优点。但是对于RoR，我自己没有使用过使用，很难说RoR中的项目应该是什么样子。我没有仔细对比过RIFE，它看起来受了RoR影响，尤其是类似ActiveRecord的数据访问层。但是如果你的应用需要特定的URL格式，那么在Tapestry中奋战胜算不大。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />在这两年来我没怎么尝试过Tapestry以外的东西。我没怎么学习RoR，因为时间太有限了。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />Tapestry 4.0有很好的Ajax支持，通过Tacos库。而Tapestry 4.1还要进一步强化这方面的支持。<br />Tapestry 5.0提供了明显的改进：没有abstract类（Tapestry的怪癖:）。没有强迫的继承关系。对属性进行annotation而不是方法。没有XML，只有模版和annotaions。只能类装载，自动寻找类的变化。最小化API，超越annotaion。面向方面（Aspect-oriented）模块构造，使用mix-ins。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />Tapestry 3.0还不容易测试，4.0改善了一些。Tapestry只是个人秀；实际上我们有很多活跃的贡献者。Tapestry的学习曲线非场陡峭。它只有漂亮的模版实现；实际上Tapestry的特点在于状态管理（允许对象存储状态，而不是多线程的单例来管理requests之间的游离和持久状态）<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />很有影响力。但是模版的实现非常丑陋。我听到了很多意见，关于RoR的优缺点。基于我的基本理解，这些观念对Tapestry 4产生了影响（它对Tapestry 5影响更深）。<br />RoR意味着限制了你的选择：如果你选择RoR那么就要尊旬它的实践（CoC..），看起来你的钱会花的恨值。这些类似Microsoft的哲学。而Java更崇尚给你更宽松的选择，不限定你使用的工具，但是暧昧的说这需要你对你的工具理解更深。不仅对Tapestry，还对于JEE、Spring这写entire stack的框架，需要从RoR学习，不仅提供工具，还需要提供整套的解决方案。</p>
		<p>
				<font size="6">
						<strong>
								<font size="5">Trails(Chris Nelson)</font>
						</strong>
				</font>
				<br />
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />Trails的应用程序只需要Web界面和持久化的domain model就可以了。Trails给你的domain model快速的提供一个界面，除了POJO自己不需要附加的代码。Trails允许你修改界面的外观和行为，包括验证、i18n、安全。这些都不需要java代码生成，不喜欢代码生成的人应该感觉很舒适。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />Trails讲究够用就好。它允许你快速交付，问问你的客户：“这样够好么？”。这会改变你的工作流程，当然这不是可以覆盖所有需求的解决方案。当UI需求很高，Trails没有优势。我认为Trails适合于混合的应用，对于管理员他们只需要够用就好，那么就可以使用Trails。其它的部分我们可以订制开发，我们在使用Tapestry、Hibernate、Spring来实现这些部分，Trails正是基于它们。对于非交互的应用，Trails也不适合，如报表应用，可以考虑Eclipse BIRT。<br />3<strong>、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />我用Struts很多。它曾经是伟大的framework。主要的缺陷是它不能自动帮定数据到domain model。我也研究过JSF，它比Struts强，但是自定义组建非常难。Tapestry非常便于自定义组建，尤其对于建立高阶组件（有其它组件组成的）非常方便，Trails正在使用它。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />对于Trails来说我们站在巨人的肩膀上。Tapestry在ajax功能作了很多努力，所以Trails也不难与其共舞。但是我们需要创建更多的例子来演示这些。我们也致力于让Trails容易介入到已经进行的项目中。以后Trails还要加入基于实例的安全（instance-based security）（目前正在使用基于角色的role-based），还有method invocation。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />Trails是对RoR的移植。Trails的名字来自Rails。它是基于Rails的理念，但不是对它的移植。<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />我认为我们有很多需要从RoR学习的地方，那将帮助我们享受开发Web程序的惬意。</p>
		<p>
				<font size="6">
						<strong>
								<font size="5">WebWork(Patrick Lightbody)</font>
						</strong>
				</font>
				<br />
				<strong>1、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong>
				<br />一般来说，WebWork一般适合小的团队，它们愿意保持一双脏手，学习开元工具如何使用。WebWork不面向“轮椅程序员”，那些人只喜欢拖拽式的开发。WebWork给花时间学习它的人回报。例如，直到输入和输出的人（阅读了参考文档，那样很好）能够容易的创建ActionMapper和Configuration实现来提供“惯例”代替配置（CoC）的方便。我最近的例子中，URL是这样“/project/123/suite/456/test/create”影射到“com.autoriginate.actions.project.suite.test.CreateAction”，然后自动的传递参数：projectId=123、suiteId=456。而Result是“[action].jsp”或者“[action]-[result].jsp”，也可以通过annotation来配置。<br />也就是说，WebWork是你的应用程序framework中的最佳基础工具。在这种情况以外也很好，但是目前不算最佳的“甜点”。<br />除去这些一般的，WebWork对于正在创建需要插件和扩展的产品的人是必备的。例如JIRA、Confluence、Jive Forums。因为WebWork支持广泛的模版语言（Velociy和FreeMarker），完整的tag支持，模块写好后非常容易插入。一个jar包就可以包括所有的action和view（得益于ftl的classpath支持）。最终的效果很好：在Confluence中你可以通过管理界面上传一个jar，这个plug-in就会自动部署。这是因为Atlassian（Confluence、Jira的小组）非常了解这个framework，并且作了很多的贡献。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？</strong><br />与其它action framework相同，WebWork在控制状态和wizards上比较弱。如果你写了很多长的wizards，JSF可能是比较好的解决方案。我还想说，文档还需要改善（参考文档还不错，但是教程、cookbooks和FAQ还比较差），如果没有一个WebWork高手作为项目领队，新手可能会敬而远之。<br />对于非常简单的程序，我推荐使用简单的JSP或者Spring MVC，如果用户接受Spring的话。但是总的来说，我认为在action framework中WebWork是最好的。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？<br /></strong>我试验过RIFE、Spring MVC、Struts、Spring Web Flow，还有一点点Tapestry。我发现RIFE的概念很优秀，但是它的实现不怎么样。不难想象Geert还是使用“m_”作为字段的前缀。它看起来不像Java。模版难住了我，所以就没有继续看。<br />Spring MVC还可以，但是它是一个非常简单的framework实现。WebWork的数据绑定（WebWork世界中称为类型转换）要强多了，而且是自动的（而Spring需要自己写property editors）。在Spring中的view替换支持泰有限了，而WebWork中的UI tags在Spring中压根没有提供。Spring中你可以使用JSP 2.0轻松的写自己的tag，但是不支持其它的语言。<br />Spring Web Flow：XML让我抓狂。太过火了，不管Keith的主张，它“不支持任何的Web framework”。这个web framwork回避掉了WebWork、Spring MVC、Struts或者其它framework中的99%。我倒不是说这是个坏主意，但是我应该诚实的说它是一个完整的框架。<br />Tapestry很优雅，但是HTML属性（jwcid）惹人厌。我接受这种理念，且实践中这会带来一些好处（Shale也有相似的地方）。但是实际上，我发现“HTML/CSS开发者”和“app开发者”一般是同一个人，Tapestry就架设如此。实际上，由于Ajax的推动，我想越来越多的“程序逻辑”会被嵌入到UI；这样的话，Tapestry的模型就不那么适宜了。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />在Struts Action 2.0我们希望：更好的文档。支持标准（如果可以，我们希望用JSTL代替OGNL，但是首先要保证不会有功能损失）。增强AJAX支持，提供更多的widgets：如自动完成。解除配置地狱；提供更多的选择，如我们开始所说的CoC。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />他需要很多的配置：我已经演示过，通过CoC风格，它可以做的比Rails更好（Rails的管理部允许内嵌controllers）。<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />非常重要的一点是，我要说RoR不能与大多数的framework对比，除了RIFE和Seam。对比RoR和WebWork就相当于对比Hibernate和JDBC。一个是full stack，另一个只是stack中的一部分。<br />另一个重要的问题：DHH是个怪胎，但是聪明的怪胎。它的高效率无可争辩，它被称为Rails。<br />好的，我们不说这个，随便说说别的：<br />我使用Rails创建了一个小的app。我把它扔掉并很快用Java重写了。我认为Rails可以让你的app中的80%快速完成；而剩下的20%比前面80%需要花的时间还多。当然程序开发就是这样。脚手架非常酷，尤其是ActiveRecord在运行时改变类。但是后来你需要写UI、自定义的验证规则，自定义安全影射等等。一个基于CRUD的app能够在30分钟内运行并不意味着你能以这个速度完成它。<br />Rails的web framework部分相比于WebWork很可怕。实际上根本无法比较。它的实现更接近于Spring MVC的简单功能。<br />完整的stack非常棒。他们在这方面做得很好，这里Java还有差距需要追赶。WebWork是web stack，但是持久化解决方案并不确定。所以最大的问题在于即使WebWork和SiteMesh提供了如配置动态读取和动态类reloading，Spring、iBatis和Hibernate并不提供。它们至少需要提供配置重读取后才可以发展出类似Rails那样的功能。类似的，Hibernate和iBatis对WebWork等的请求提供的支持不够。对于一个类，我可以不需要再xwork.xml中进行配置，但是持久化引擎并不允许我们这样做。当这些功能能够同时具备，没准一个complete stack的框架就会推出。<br />要求快5倍10倍是愚蠢的。可靠的工程师都知道开发产品的时候最大的警力都花费在构思代码上，而不是书写代码。定义需求，获取反馈，市场定位，定义数据库结构，映射用户接口。不管使用什么语言，你需要思考很长时间。没有语言或者框架能够提升思考的速度。<br />最后，Rails提供了：用脚本语言良好实现的stack。Python、Perl尤其是PHP中的其它框架还没有成熟。我认为“PHP猴子”们还有很多事情要做，他们通常不是很有才干的工程师。（可能我翻译错误了，希望纠正）。在脚本语言中提供良好的框架，人们能够实现设计精良的app并的到回报（因为脚本语言的特点）。不只是“管理代替配置CoC”甚至是集成stack，Java需要的是立刻反射出变化的能力。很多Java开源领袖认为“修改web.xml”的重新载入是一种方法。这种智力游戏应该结束了。我们不仅仅需要配置文件和类的重新载入，我们需要社区给Sun足够的压力，使其能够在下一代的JVM中提供热插拔（HotSwap）的能力。或者，更加复杂的程序模型，如OSGi，需要进一布被社区所接受。当然我并不希望走那条路线。</p>
		<p>
				<font size="5">
						<strong>Wicket(Eelco Hillenius)</strong>
						<br />
				</font>1<strong>、你认为你的framework的“甜点”在哪里？他最适合哪种类型的项目？</strong><br />我认为有5点：Wicket是以代码为中心的：可以在view层进行OO编程。组件是完全自管理的：容易创建和重用。概念的分离是清晰的也是强迫的。干净的模版。开发伸缩性大-就像OO一样。<br /><strong>2、它不适合于什么样的场景？在这些场景你推荐什么fremework？它是哪个？<br /></strong>Wicket不适合UI很简单且只读的场合。这时页面脚本更加适合，比如JSP，或者JSF。如果你需要无限的可伸缩性，你可能需要状态无关的实现。从1.2版开始，Wicket也有无状态页面的概念，这样可伸缩性与其它framework差不多了。<br /><strong>3、在下面提到的framework中，你试验过他们么？如果试验过，你比较喜欢哪个？你不喜欢哪个？</strong><br />JSF：<br />优点：基于组件。工业背景。工具支持。一些扩展让他更容易使用。它允许你从传统JSP升级到JSF。<br />缺点：它缺少其它API的优雅。以JSP为中心。配置很多而且代码很难看。有很多种实现。它让我回忆起EJB1/2，以厂商为中心等等。<br />RIFE：没用过，说了一大堆。<br />Seam：不是一个真正的Web framework。类似JSF扩展。如果使用EJB/JSF/JBoss组合，这个选择很好。但是不遵循JSR 227/235。<br />Tapestry：很好，4.0版本好了很多。我把它推荐给我所工作的公司。Wicket更加以编程为中心。而Tapestry更加pragmatic。<br />Trails：从来没用过。<br />Spring Web Flow：framework本身很好，但是我不喜欢它的stacking。如果用工作流，我希望选择一个如jBMP的方案。我也不喜欢以流为中心的解决方案，认为这样很过程化。<br />WebWork、Spring MVC、Struts：Model 2的framework糟透了。我用过几年，也对Maverick贡献过代码，但是我彻底失去兴趣了。Model 2 framework太过程化了，这些程序员不知道怎么用OO编程。我宁可雇佣一个Swing编程的人也不会去选择一个使用Model 2 framework编程的人，因为Swing编程的人写的程序一般更漂亮。……如果让我从这些Model 2 framework中挑一个出来，我选择Stripes，它抛弃了model 2中的一些不好的方面。<br /><strong>4、你的framework的未来会怎样？对于用户开发会有什么方便使用的变化？你会原生支持Ajax么？你们计划支持它了么？</strong><br />我们将会支持Java5。我们会增强Spring支持，复杂的权限认证支持，和基于角色的参考实现，还会提供原生AJAX支持，URL加载（nice URLs），无状态页等。<br />我们的市场占有率不高，但是用户群在提高。我正在写“Wicket In Action”（Manning出版）正在筹划中，今年夏天会出版。<br /><strong>5、有对你们的framework的传言需要澄清么？如果有，是哪个？</strong><br />关于伸缩性的问题是第一位的。程序的可伸缩型一般是由数据库性能差或者缓存策略查询优化并发等问题。服务器端可伸缩性并不一定不可扩展，可以通过集群来继绝。……<br /><strong>6、你对Ruby on Rails的看法如何？</strong><br />我喜欢我看到的Ruby，如果我有时间我还会仔细把玩它。如果不是Wicket的问题，我希望更多的实践RoR。……</p>
<img src ="http://www.blogjava.net/iamtin/aggbug/38276.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-03-30 16:28 <a href="http://www.blogjava.net/iamtin/archive/2006/03/30/WebFrameworkSweetSpots.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Webwork 2.2.2新增的ww:date的用法</title><link>http://www.blogjava.net/iamtin/archive/2006/03/28/37865.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Tue, 28 Mar 2006 12:00:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/03/28/37865.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/37865.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/03/28/37865.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/37865.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/37865.html</trackback:ping><description><![CDATA[
		<p>今天浏览WW的Wiki，结果无意发现ww:date标签的用法，挠头一想以前没有见过呀，仔细一看原来是2006/3/21才加上的。<br />会头看看项目发现用的ww 2.2.1中没有这个标签，心想是不是发布新版本了？<br />果不出所料！发现OPENSYMPHONY已经发布2.2.2了。<br />不过2.2.2是在Opensymphony下的最后一个版本了，以后的版本就会以Struts Action 2.0的形式发布了，而后者今年8月才发布，中间的日子估计只能靠nightly build了。<br />说说变化，发现增加了RichTextEditor，经考察就是我们熟悉的FCK Editor。发现还增加了nifty corners，这是一个不用images的圆角容器（css+js），估计用在了某个theme里面。还有J2SE5的支持也更加完善，现在已经可以支持泛型Collection的反射（无需-conversion文件了），还支持annotation风格的validation声名（如此像Stripes那样的Web框架就没什么可吹嘘的了）。其它的变化请参考他们的ReleaseNotes。<br /><a href="http://www.opensymphony.com/webwork/wikidocs/Release%20Notes.html">http://www.opensymphony.com/webwork/wikidocs/Release%20Notes.html</a></p>
		<p>说说新添加的ww:date标签。很多朋友可能都认为ww:property输出date比较不如意，以前很多解决方案感觉都不够灵活。WW肯定察觉了，新增加的ww:date把玩了一下发现非常好用，所以推荐给大家。<br />语法非常简单：<br />name：你取值的ognl表达式<br />nice：是否使用易读（readable notations）的模式，其实就是类似conflunce里面显示时间的方式，类似“in 2 hours, 14 minutes”<br />format：就是我们常用的时间format，例如“yyyy-MM-dd hh:mm”<br />id：就是HTML中的元素id</p>
		<p>使用起来如下，官方的例子：<br />&lt;ww:date name="person.birthday" format="dd/MM/yyyy" /&gt;<br />按照“dd/MM/yyyy”格式显示<br />&lt;ww:date name="person.birthday" format="%{getText('some.i18n.key')}" /&gt;<br />将format定义到i18n文件中的方式，这个很常用:D<br />&lt;ww:date name="person.birthday" nice="true" /&gt;<br />使用易读（readable notations）的模式<br />&lt;ww:date name="person.birthday" /&gt;<br />使用默认的格式输出</p>
		<p>其中显示的规则如下：<br />1、如果制定了nice="true"则优先以易读（readable notations）的模式显示<br />2、如果nice="false"则按照指定的format显示<br />3、如果上面两个属性都没有指定，则从默认的资源文件中寻找webwork.date.format这个i18n的key，按照它显示<br />4、如果还没有找到则按照DateFormat.MEDIUM格式显示<br />5、特别之处：如果从ValueStack没有找到值，则默认显示空白（而不是null）</p>
		<p>就这么简单，感觉读（readable notations）模式尤其有趣，非常好用，你还可以给它指定i18n的显示方式。<br />下面共享一下我写的zh_cn版本，你只需要将一下内容拷贝到classpath下面的default.properties文件中就可以了（也可以按照i18的资源文件命名规则）：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">webwork.date.format.past</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} 以前<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.future</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">在 {</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.seconds</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">几秒钟前 <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.minutes</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#一分钟|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} 分钟} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.hours</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#一小时|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} 小时}{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">#|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#零一分钟|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;零 {</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">} 分钟} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.days</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#一天|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} 天}{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">#|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#零一小时|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;零 {</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">} 小时} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.years</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#一年|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} 年}{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">#|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#零一天|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;零 {</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">} 天} </span>
		</div>
		<p>输出的样子如：“一天零 8 小时 以前”，“4 天零 23 小时 以前”……</p>
		<p>你也可以自己翻译，默认的key如下：<br />i18n文件默认为default.properties</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">webwork.date.format.past</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} ago <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.future</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">in {</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.seconds</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">an instant <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.minutes</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#one minute|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} minutes} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.hours</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#one hour|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} hours}{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">#|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> one minute|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> {</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">} minutes} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.days</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#one day|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} days}{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">#|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> one hour|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> {</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">} hours} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />webwork.date.format.years</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#one year|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;{</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">} years}{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">choice</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">#|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">#</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> one day|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> {</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">} days} </span>
		</div>
		<p>为2.2.2的Webwork发布兴奋之余也为它的未来有些担心，到Struts Action Framework发布还有挺久，其中的真空期很难等待呀，WW一向有些小毛病，靠nightly build改善还是很麻烦的。<br />2.2.2的更多功能的探索希望大家能够互相交流。</p>
		<p>还有点补充：现在用ww:property输出Date类型的数据默认会显示到毫秒……请注意。</p>
<img src ="http://www.blogjava.net/iamtin/aggbug/37865.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-03-28 20:00 <a href="http://www.blogjava.net/iamtin/archive/2006/03/28/37865.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[犯弱]偶遇奇怪的“浏览器兼容问题”</title><link>http://www.blogjava.net/iamtin/archive/2006/03/14/35301.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Tue, 14 Mar 2006 13:12:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/03/14/35301.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/35301.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/03/14/35301.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/35301.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/35301.html</trackback:ping><description><![CDATA[遇到了一个奇怪的“浏览器兼容问题”……<BR>是这样的，登陆页面工作不正常，在firefox下总是没有登陆，根本就没有触发webwork的filter dispatcher。<BR>打开我的三剑客：IE、Firefox、Opera测试，发现只有Firefox不行（Mozzila内核的都不行）。<BR>然后花了3个多小时找原因，翻遍网络：weblogic、webwork、fireforx所有关键词都搜索了，没有收获。<BR>然后开始sniffer，看报文。<BR>经过多次分析，发现firefox根本就没有post那个form！<BR>然后又是继续的分析还是无果，一筹莫展……<BR>然后旁边同事大喊，你这&lt;input type="submit".../&gt;外面怎么嵌套了一个&lt;a&gt;呀！<BR>我当场晕菜，原来以前静态演示这里放了个&lt;a&gt;……结果后来犯傻把&lt;input&gt;写在了里面，而firefox对a的解释和IE不同，结果a的内容优先于input，结果没有post而只是触发了a的fref&nbsp; 我#$#&amp;U$#*&amp;$……<BR>没话说了，绝对的弱智行为。结绳记事，以绝后患。<BR>注意&lt;a&gt;和其它元素嵌套时浏览器的解释差异，这是个小错，谁知还会有什么大错？<IMG height=19 src="http://www.blogjava.net/Emoticons/74_74.gif" width=19 border=0><img src ="http://www.blogjava.net/iamtin/aggbug/35301.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-03-14 21:12 <a href="http://www.blogjava.net/iamtin/archive/2006/03/14/35301.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Webwork中使用ww:action实现页面控制器风格Action复用</title><link>http://www.blogjava.net/iamtin/archive/2006/03/10/34666.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Fri, 10 Mar 2006 06:45:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/03/10/34666.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/34666.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/03/10/34666.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/34666.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/34666.html</trackback:ping><description><![CDATA[<P>Webwork是标准的请求风格Web MVC，类似的有Struts、Spring MVC。这这种风格的MVC中都使用了前端控制器模式（企业架构模式），也就是说一个URL会被解析然后派发到对应的Action解析，而View调用的是Action处理后的Form对象或者Command对象（Rod的Without EJB）。<BR>上面引用了一些经典的言论，而它们和“页面控制器风格Action复用”有什么关系呢？<BR>嘿嘿，页面控制器在这里指到了View的Page里面依然可以调用控制器（在Webwork中就是Action）。如果是以前肯定有人会说，如果用JSP我随时可以在Page里面写scriptlet，什么东西都能调用……<BR>可是，现在不一样了。我们希望让View单纯一点，不要有杂乱无章的逻辑参与其中。<BR>可是，如果要是如上面所说那么Action在它的一个请求生命周期就要做所有的事……这样一是使Action逻辑变得复杂，二是会变得难以复用。<BR>所以，说到这里就引出了这个主题：<BR>1、在页面调用控制器<BR>2、复用控制器逻辑<BR>在Webwork中我们可以使用&lt;ww:action/&gt;标签实现这个目的。<BR>——————————————————————————————————————<BR>不要着急，我们先介绍一下ww:action的两种主要用法，而说用法之前先说语法：<BR>语法：<BR>&lt;ww:action/&gt;有5个属性：<BR>1、id：给Action返回的ValueStack命名，如果不写则默认为调用的Action的名字。（详细使用参照后面）<BR>2、name：调用的Action的name。<BR>3、namespace：调用的Action的namespace。<BR>4、executeResult：true或false，是否渲染Action的View。这个决定了ww:action的用法。（后面会做说明）<BR>5、ignoreContextParams：Boolean值，request参数是否在Action被调用时所包括。</P>
<P>好了，语法很简单，我们说ww:action的两种主要用法。<BR>1、代替&lt;jsp:include&gt;：<BR>include有两种方式@ include和jsp:include，它们一个是编译前一个是运行时include。webwork是不能使用&lt;jsp:include&gt;的。<BR>但其实ww有ww:include标签，但是根据Webwork in Action中的推荐，ww:include标签适合调用一般servlet，而对于action则推荐使用强大的ww:action。所以我们这里就略过ww:include。<BR>说强大是什么意思呢？ww:action充当这个角色时，可以选择是否将valueStack的东西复制过来。<BR>当ww:action代替jsp:include的时候我们需要executeResult="true"，这个时候调用的action返回的view会被include到调用的位置。&lt;ww:action&gt;&lt;param name="xxx" value="yyy"/&gt;&lt;/ww:action&gt;则可以给action传递参数。其它的用法就与jsp:include或者ww:include用法差别不大了。</P>
<P>2、页面控制器风格Action复用：<BR>我们经常遇到这样的场景，比如用户注册的时候需要选择单位列表。那么我们reg.action运行之前就需要先把单位列表unitsList取出来。而它们本身与User注册逻辑上没什么关系。<BR>所以有的人把这个取出unitsList单独写在prepare()方法里面，然后用prepare Inteceptor……或者把读取unitsList的逻辑写在execute方法里面。<BR>但是这显然难以复用！<BR>其实如果有单位unit这样的domain，我们可能就有对应的CRUD的Action。其中可能就有UnitsListAction这样的Action。<BR>我们完全可以在用户注册的时候就复用这个Action，而不是把同样的逻辑写到用户注册的Action里面。这就是页面控制器风格要解决的问题。<BR>说那么多大帽子其实没有意义，我们看看怎么实现：<BR>UnitsListAction片断（我们要复用它）：</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">UnitService&nbsp;unitService&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">注入，商业逻辑</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">List</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">Unit</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;unitsList&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">设置对应getter、setter</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000"><BR>Public&nbsp;String&nbsp;execute()&nbsp;{<BR>&nbsp;unitsList&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unitDao.listAll();<BR>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;SUCCESS;<BR>}<BR></SPAN></DIV>
<P>UserRegAction假设在注册前只是doDefault()直接返回SUCCESS，只有在Post数据时在调用execute()，我们就不写空的代码了。或者不通过任何Action调用注册页面，直接调用注册的jsp文件直接访问也可以。</P>
<P>到了UserRegAction显示的View，我这里是Jsp片断：</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:action&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="listUnits"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;executeResult</SPAN><SPAN style="COLOR: #0000ff">="false"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;namespace</SPAN><SPAN style="COLOR: #0000ff">="/"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="unitsListAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:select&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="unitId"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;list</SPAN><SPAN style="COLOR: #0000ff">="#attr.listUnits.unitsList"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;listKey</SPAN><SPAN style="COLOR: #0000ff">="id"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;listValue</SPAN><SPAN style="COLOR: #0000ff">="name"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;required</SPAN><SPAN style="COLOR: #0000ff">="true"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN></DIV>
<P>注意，executeResult="false"，也就是说我们不渲染unitsListAction返回的view，只用它的值。<BR>而访问它的值的时候要使用#attr.listUnits.unitsList这样的引用，因为这时unitsListAction返回的VlueStack不是页面的ognl的rootStack，我们需要访问#attr这个Stack，这部分可以参考一下Webwork的wiki。<BR>上面我给unitsListAction规定了一个id，这样调用比较灵活，你可以多次调用同一个Action并且将值放在#attr下的不同地方。<BR>我们引用unitsListAction返回的unitsList这个list的时候需要用#attr加上我们给unitsListAction设定的id（如果不指定id，则默认unitsListAction）再加上你要访问的变量名访问。<BR>其实很简单，而这种方式就是开始说的页面控制器风格的action复用。虽然和真正的叶面控制器的Tapestry和JSF相差甚远，但是也算有点那个意思了。<BR>扩展点想，如果我们在Action实现了一个counter，也可以通过这种方式调用，连返回的值都可以忽略，呵呵，这种逻辑复用还是挺有用的。</P>
<P>抛砖引玉，我这个人说话啰嗦，见谅，就到这里。</P><img src ="http://www.blogjava.net/iamtin/aggbug/34666.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-03-10 14:45 <a href="http://www.blogjava.net/iamtin/archive/2006/03/10/34666.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何给Webwork的redirect的result传递多个参数</title><link>http://www.blogjava.net/iamtin/archive/2006/02/24/32290.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Fri, 24 Feb 2006 05:56:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/02/24/32290.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/32290.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/02/24/32290.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/32290.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/32290.html</trackback:ping><description><![CDATA[<P>今天遇到一个问题，在Webwork 2.2里面给一个Action的result传多个参数：<BR>原先配置如下</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">action&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="blahblahAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;class</SPAN><SPAN style="COLOR: #0000ff">="blahAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;method</SPAN><SPAN style="COLOR: #0000ff">="blah"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">result&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="success"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="redirect"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">/some.action?field1=${field1}</SPAN><SPAN style="COLOR: #ff0000">&amp;field2</SPAN><SPAN style="COLOR: #000000">=${field2}</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">result</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">action</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>
<P>运行时候出现如下提示：<BR>The reference to entity "field2" must end with the ';' delimiter.<BR>我本以为是OGNL的问题，四处搜寻，不得其解……看了DTD也没有发现问题。<BR>后来修改过程中突然发现原来是SAX解析器出错，我这才想到可能是XML的问题。<BR>经过再三查询得到解决方案：<BR>使用"&amp;amp;"代替"&amp;"，原理和HTML中的转义相同，我居然忘记了XML的语法规范，惭愧。<BR>配置如下：</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">action&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="blahblahAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;class</SPAN><SPAN style="COLOR: #0000ff">="blahAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;method</SPAN><SPAN style="COLOR: #0000ff">="blah"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">result&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="success"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="redirect"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">/some.action?field1=${field1}</SPAN><SPAN style="COLOR: #ff0000">&amp;amp;</SPAN><SPAN style="COLOR: #000000">field2=${field2}</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">result</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">action</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>
<P>工作正常了！希望对大家有用。<BR>这几天超忙，没怎么写Blog，还是要勤呀。</P><img src ="http://www.blogjava.net/iamtin/aggbug/32290.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-02-24 13:56 <a href="http://www.blogjava.net/iamtin/archive/2006/02/24/32290.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>webwork 2.2 中如何给Collection赋值</title><link>http://www.blogjava.net/iamtin/archive/2006/02/16/31099.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Thu, 16 Feb 2006 13:19:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/02/16/31099.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/31099.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/02/16/31099.html#Feedback</comments><slash:comments>9</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/31099.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/31099.html</trackback:ping><description><![CDATA[<P>原本javaeye有这么一篇帖子“在WebWork2 Action中如何自动设置Array、List、Map”，是moxie大哥写的。 <BR><A href="http://forum.javaeye.com/viewtopic.php?t=8770">http://forum.javaeye.com/viewtopic.php?t=8770</A> </P>
<P>但是已经是2004年11月的文章了，在webwork 2.2 b4中，XWorkList和XWorkMap已经是deprecated状态了，当时我就一头雾水，也没找到什么好的线索。 <BR>去java.net下载了XWork的最新代码，看到了其中的注释，说这个工作已经可以自动完成了。 <BR>又几经周折，才算搞明白先在如何让List、Map等工作起来，给予2.2 b4和b5工作正常： </P>
<P>下面简单介绍一下： <BR>1、如果要将值映射到pojo的collection，则需要使用conversion功能。 <BR>如我又一个Action，叫testAction： </P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_46_804_Open_Image onclick="this.style.display='none'; Codehighlighter1_46_804_Open_Text.style.display='none'; Codehighlighter1_46_804_Closed_Image.style.display='inline'; Codehighlighter1_46_804_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_46_804_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_46_804_Closed_Text.style.display='none'; Codehighlighter1_46_804_Open_Image.style.display='inline'; Codehighlighter1_46_804_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;testAction&nbsp;</SPAN><SPAN style="COLOR: #0000ff">extends</SPAN><SPAN style="COLOR: #000000">&nbsp;ActionSupport&nbsp;</SPAN><SPAN id=Codehighlighter1_46_804_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_46_804_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;Collection&nbsp;smoeAttrs&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">（使用webwork自动负值，应有对应getter和setter）&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;IDeptJgzTjkEcoAttDAO&nbsp;ecoAttDAO&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">（改DAO使用Spring注入，应有相应setter）&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_269_801_Open_Image onclick="this.style.display='none'; Codehighlighter1_269_801_Open_Text.style.display='none'; Codehighlighter1_269_801_Closed_Image.style.display='inline'; Codehighlighter1_269_801_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_269_801_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_269_801_Closed_Text.style.display='none'; Codehighlighter1_269_801_Open_Image.style.display='inline'; Codehighlighter1_269_801_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;String&nbsp;execute()&nbsp;</SPAN><SPAN style="COLOR: #0000ff">throws</SPAN><SPAN style="COLOR: #000000">&nbsp;Exception&nbsp;</SPAN><SPAN id=Codehighlighter1_269_801_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_269_801_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG id=Codehighlighter1_314_401_Open_Image onclick="this.style.display='none'; Codehighlighter1_314_401_Open_Text.style.display='none'; Codehighlighter1_314_401_Closed_Image.style.display='inline'; Codehighlighter1_314_401_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_314_401_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_314_401_Closed_Text.style.display='none'; Codehighlighter1_314_401_Open_Image.style.display='inline'; Codehighlighter1_314_401_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(log.isDebugEnabled())&nbsp;</SPAN><SPAN id=Codehighlighter1_314_401_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_314_401_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">performing&nbsp;execute()&nbsp;method!</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">持久化collection里面的pojo&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_545_722_Open_Image onclick="this.style.display='none'; Codehighlighter1_545_722_Open_Text.style.display='none'; Codehighlighter1_545_722_Closed_Image.style.display='inline'; Codehighlighter1_545_722_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_545_722_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_545_722_Closed_Text.style.display='none'; Codehighlighter1_545_722_Open_Image.style.display='inline'; Codehighlighter1_545_722_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">&nbsp;(Iterator&nbsp;iterator&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;smoeAttrs.iterator();&nbsp;iterator.hasNext();)&nbsp;</SPAN><SPAN id=Codehighlighter1_545_722_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_545_722_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SomeAttr&nbsp;someAttr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(SomeAttr)&nbsp;iterator.next();&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ecoAttDAO.saveOrUpdate(someAttr,&nbsp;someAttr.getId());&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Action.SUCCESS;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P>对应一个pojo： </P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">package</SPAN><SPAN style="COLOR: #000000">&nbsp;org.tin.test;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_70_361_Open_Image onclick="this.style.display='none'; Codehighlighter1_70_361_Open_Text.style.display='none'; Codehighlighter1_70_361_Closed_Image.style.display='inline'; Codehighlighter1_70_361_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_70_361_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_70_361_Closed_Text.style.display='none'; Codehighlighter1_70_361_Open_Image.style.display='inline'; Codehighlighter1_70_361_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;SomeAttr&nbsp;</SPAN><SPAN style="COLOR: #0000ff">implements</SPAN><SPAN style="COLOR: #000000">&nbsp;Serializable&nbsp;</SPAN><SPAN id=Codehighlighter1_70_361_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_70_361_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_82_120_Open_Image onclick="this.style.display='none'; Codehighlighter1_82_120_Open_Text.style.display='none'; Codehighlighter1_82_120_Closed_Image.style.display='inline'; Codehighlighter1_82_120_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_82_120_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_82_120_Closed_Text.style.display='none'; Codehighlighter1_82_120_Open_Image.style.display='inline'; Codehighlighter1_82_120_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_82_120_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**&nbsp;*/</SPAN><SPAN id=Codehighlighter1_82_120_Open_Text><SPAN style="COLOR: #008000">/**</SPAN><SPAN style="COLOR: #008000">&nbsp;The&nbsp;composite&nbsp;primary&nbsp;key&nbsp;value.&nbsp;</SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;java.lang.Long&nbsp;id;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;java.lang.Float&nbsp;fild1;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;java.lang.String&nbsp;fild2;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;java.util.Date&nbsp;fild3;&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_289_358_Open_Image onclick="this.style.display='none'; Codehighlighter1_289_358_Open_Text.style.display='none'; Codehighlighter1_289_358_Closed_Image.style.display='inline'; Codehighlighter1_289_358_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_289_358_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_289_358_Closed_Text.style.display='none'; Codehighlighter1_289_358_Open_Image.style.display='inline'; Codehighlighter1_289_358_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_289_358_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_289_358_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">.&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;对应的getter和setter&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P>可以看到，上面的Action声明的时候没有任何涉及到XWorkList的地方（moxie介绍的那种风格），也就是说现在webwork并不知道Collection里面放的pojo的类型。这就是Webwork目前的高明之处，这样的代码非常干净。但是如果要自动设定Collection的值，访问到这些Pojo，则一定要知道Pojo的类型，Webwork如何做呢？ <BR>通过-conversion配置。 <BR>需要在对应该才那个testAction.java的相同目录写一个testAction-conversion.properties文件（格式就是Action名字+“-conversion.properties”）。 <BR>文件里面注明： <BR>Element_someAttrs = org.tin.test.SomeAttr （以前版本曾经用过Collection、Map分开，但是现在不管什么类型，都用Element） <BR>格式就是“Element_”+Action中Collection的名字+“=”+你的pojo的完整类名 </P>
<P>如此配置后，自动设置值的时候就可以知道你的pojo的类型了，很干净。 </P>
<P>下面一小段由于我接触Webwork不久，所以是个很初级的经验，如果需要则自取： <BR>回忆moxie帖子中的重要的部分，在post到相应action的页面的form中，input要遵循这样的命名： <BR>对应刚才所说的那个pojo： </P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[0].fild1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="45555.6"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx11"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[0].fild2"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="test"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx12"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[0].fild3"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="2006-01-05"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx13"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[1].fild1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="45555.6"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx21"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[1].fild2"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="test"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx22"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[1].fild3"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="2006-01-05"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx23"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[2].fild1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="45555.6"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx31"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[2].fild2"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="test"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx32"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[2].fild3"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="2006-01-05"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="xxx33"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>
<P>如何输出？很简单，在列表页中：&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:iterator&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="someAttrs"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;status</SPAN><SPAN style="COLOR: #0000ff">="someAttrsIter"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:hidden&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[%{#someAttrsIter.index}].id"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="%{id}"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:textfield&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[%{#someAttrsIter.index}].fild1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="%{fild1}"</SPAN><SPAN style="COLOR: #0000ff">/&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">ww:textfield&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[%{#someAttrsIter.index}].fild2&nbsp;value="</SPAN><SPAN style="COLOR: #ff0000">%{fild2}"</SPAN><SPAN style="COLOR: #0000ff">/&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">ww:textfield&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="someAttrs[%{#someAttrsIter.index}].fild3"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="%{fild3}"</SPAN><SPAN style="COLOR: #0000ff">/&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">td</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">tr</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ww:iterator</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>
<P><BR>即可以，因为iteratror这个tag支持iteratroStatus这个东西，用它可以获取index、isOdd等信息，很方便。 </P>
<P>配合 </P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">action&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="saveAction"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;class</SPAN><SPAN style="COLOR: #0000ff">="testAction"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">result&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="success"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="redirect"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">/loadByInf.action?id=${someAttrOwner.id}</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">result</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">action</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>
<P>则很容易的实现对Collection的CRUD。正好用到了ONGL的集中基本访问方式：#、%{}、${} </P>
<P>以上内容，错漏难免。因为今天终于可以偷闲，赶紧结绳记之。欢迎大家讨论更简便的方法。</P>
<P>&nbsp;</P><img src ="http://www.blogjava.net/iamtin/aggbug/31099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-02-16 21:19 <a href="http://www.blogjava.net/iamtin/archive/2006/02/16/31099.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Webwork22b5中datapicker的本地化使用方法</title><link>http://www.blogjava.net/iamtin/archive/2006/02/16/31098.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Thu, 16 Feb 2006 13:15:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/02/16/31098.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/31098.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/02/16/31098.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/31098.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/31098.html</trackback:ping><description><![CDATA[<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width="100%"><A href="http://forum.javaeye.com/viewtopic.php?p=108492#108492"><IMG title=文章 height=9 alt=文章 src="http://forum.javaeye.com/templates/subSilver/images/icon_minipost.gif" width=12 border=0></A><SPAN class=postdetails>时间: 2006-1-05 19:00:49<SPAN class=gen>&nbsp;</SPAN>&nbsp; &nbsp;标题: Webwork22b5中datapicker的本地化使用方法</SPAN></TD>
<TD vAlign=top noWrap><A href="http://forum.javaeye.com/posting.php?mode=quote&amp;p=108492"><IMG title=引用回复 alt=引用回复 src="http://forum.javaeye.com/templates/subSilver/images/lang_chinese_simplified/icon_quote.gif" border=0></A> <A href="http://forum.javaeye.com/posting.php?mode=editpost&amp;p=108492"><IMG title=编辑/删除文章 alt=编辑/删除文章 src="http://forum.javaeye.com/templates/subSilver/images/lang_chinese_simplified/icon_edit.gif" border=0></A> <A href="http://forum.javaeye.com/addblog.php?type=javaeye&amp;title=Webwork22b5中datapicker的本地化使用方法&amp;t=17936&amp;postdays=0&amp;postorder=asc&amp;start=0&amp;p=108492"><IMG title=将这个帖子加入我的Blog alt=将这个帖子加入我的Blog src="http://forum.javaeye.com/templates/subSilver/images/icon_blog.gif" border=0></A></TD></TR>
<TR>
<TD colSpan=2>
<HR>
</TD></TR>
<TR>
<TD colSpan=2><SPAN class=postbody>仅作为记录，尽量简明： <BR>1、我使用Weblogic 8.1 SP5+Webwork 2.2 beta 5。2.2b5的Webwork已经完全转向使用jscalendar作为datapicker的js，而不是以前的tigracalendar，因为tigracalendar不支持国际化。Web项目使用FilterDispatcher，本应改可以将/webwork/*的请求拦截下来，但是它工做不正常。所以我把webwork.jar里面的\com\opensymphony\webwork\static目录拷贝到Web根目录，并将static目录重名名为webwork。 <BR>此时，你的Web根目录下面应有一个名为webwork的目录，里面有jscalendar、dojo、niftycorners这几个文件加，如果不需要其它的，可以只保留jscalendar一个目录。 <BR>2、在需要显示datapicker的地方使用如下标记&lt;ww:datepicker name="ecoInf.turninDate" id="ecoInf.turninDate" template="datepicker.ftl" language="cn_utf8" format="%Y-%m-%d %H:%M:%S" showstime="true" /&gt;。 <BR>其中template完全可以不写。而name标明你的数据的来源。id是方便javascript访问所保留的，可以和name相同（如果有重复name，如经过iterator，则需要区别其id，保持id在html dom中唯一）。 <BR>showstime标明是否可以选择时间，可以是"true"，"false"，"24"，"12"。 <BR>language决定jscalendar使用的语言，参照下面说明。 <BR>3、language指定的语言其实就对应jscalendar/lang下面的语言文件，格式就是calendar-语言名.js，默认的中文使用的是zh。但是其实j2ee项目经常面对中文乱码问题，最佳解决方案就是统一使用UTF-8。但是calendar-zh.js正好不是UTF-8的，所以如果直接使用zh语言则datapicker没法正常工作。 <BR>我的解决方法是将webwork附带的jscalendar 1.0的lang里面的cn_utf8.js改名为calendar-cn_utf8.js，然后将language="cn_utf8"就工作正常了。 <BR>4、关于时间的显示格式。其实cn_utf8.js里面已经制定了时间的标准显示格式是%Y-%m-%d，符合我们的习惯。但是有时我们需要显示具体时间，参照他们网站的说明，使用format="%Y-%m-%d %H:%M:%S"，这个也符合我们的习惯。 <BR><BR>发个牢骚： <BR>本来奇简单。但是很奇怪/webwork/*居然不能在Weblogic下自动映射，我一会而去试验下Tomcat，还有就是js解析utf-8出错造成整个js没法工作，浪费了半天时间，唉。 <BR><BR>相关链接： <BR>2.2 beta 5的datapicker的doc： <BR><A href="http://wiki.opensymphony.com/display/WW/datepicker" target=_blank>http://wiki.opensymphony.com/display/WW/datepicker</A> <BR>jscalendar的官方网站： <BR><A href="http://www.dynarch.com/projects/calendar/" target=_blank>http://www.dynarch.com/projects/calendar/</A> <BR>jscalendar的使用方法简单demo： <BR><A href="http://www.dynarch.com/demos/jscalendar/" target=_blank>http://www.dynarch.com/demos/jscalendar/</A> <BR>jscalendar下载： <BR><A href="http://prdownloads.sourceforge.net/jscalendar/jscalendar-1.0.zip?download" target=_blank>http://prdownloads.sourceforge.net/jscalendar/jscalendar-1.0.zip?download</A> <BR>datapicker本地化的相关讨论： <BR><A href="http://forums.opensymphony.com/thread.jspa?messageID=21466" target=_blank>http://forums.opensymphony.com/thread.jspa?messageID=21466</A> <BR><A href="http://forums.opensymphony.com/thread.jspa?messageID=21526" target=_blank>http://forums.opensymphony.com/thread.jspa?messageID=21526</A></SPAN></TD></TR></TBODY></TABLE><BR><BR><SPAN class=postbody>昨天说要试验一下在tomcat下面的/webwork/*的映射是否工作正常。 <BR>经过试验在tomcat下面工作正常，所有com.opensymphony.webwork.static下面的东西都可以自动映射到/webwork/*下面。 <BR><BR>也就是说又是Weblogic的倒霉问题……烦啊。 <BR><BR>也就是说不用Webloigic 8.1的朋友们就可以跳过第一步了。 <BR><BR>有的朋友可能没有2.2 beta5，可以去这里下载nightly build，谢谢jscud上次提供这两个链接： <BR><A href="http://ivyrep.opensymphony.com/opensymphony/webwork/" target=_blank>http://ivyrep.opensymphony.com/opensymphony/webwork/</A> <BR>还有对应的xwork： <BR><A href="http://ivyrep.opensymphony.com/opensymphony/xwork/" target=_blank>http://ivyrep.opensymphony.com/opensymphony/xwork/</A><BR><BR>这是一篇老帖子了，已经不是最新：<BR><A href="http://forum.javaeye.com/viewtopic.php?t=17936&amp;highlight">http://forum.javaeye.com/viewtopic.php?t=17936&amp;highlight</A>=</SPAN><img src ="http://www.blogjava.net/iamtin/aggbug/31098.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-02-16 21:15 <a href="http://www.blogjava.net/iamtin/archive/2006/02/16/31098.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Webwork 2.2的Action是否使用Spring的prototype­获取的性能对比</title><link>http://www.blogjava.net/iamtin/archive/2006/02/14/30699.html</link><dc:creator>Tin</dc:creator><author>Tin</author><pubDate>Tue, 14 Feb 2006 13:48:00 GMT</pubDate><guid>http://www.blogjava.net/iamtin/archive/2006/02/14/30699.html</guid><wfw:comment>http://www.blogjava.net/iamtin/comments/30699.html</wfw:comment><comments>http://www.blogjava.net/iamtin/archive/2006/02/14/30699.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/iamtin/comments/commentRss/30699.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/iamtin/services/trackbacks/30699.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 本文在060216进行了修改，因为发现了测试中的错误！注意5.5和7的内容。1、引子：其实是ajoo的这篇“Nuts和Spring 1.2.6 效率对比”和“IoC容器的prototype性能测试 ”，他们在Javaeye上详细讨论了Spring的prototype的缺陷。Spring的prototype指的就是singleton="false"的bean，具体可以看Spring参考手册“3.2....&nbsp;&nbsp;<a href='http://www.blogjava.net/iamtin/archive/2006/02/14/30699.html'>阅读全文</a><img src ="http://www.blogjava.net/iamtin/aggbug/30699.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/iamtin/" target="_blank">Tin</a> 2006-02-14 21:48 <a href="http://www.blogjava.net/iamtin/archive/2006/02/14/30699.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>