﻿<?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-夜来风雨声的盒子-文章分类-webwork</title><link>http://www.blogjava.net/Nightlee/category/3616.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 02:34:14 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 02:34:14 GMT</pubDate><ttl>60</ttl><item><title>WebWork之Session </title><link>http://www.blogjava.net/Nightlee/articles/15877.html</link><dc:creator>夜来风雨声</dc:creator><author>夜来风雨声</author><pubDate>Wed, 19 Oct 2005 02:45:00 GMT</pubDate><guid>http://www.blogjava.net/Nightlee/articles/15877.html</guid><wfw:comment>http://www.blogjava.net/Nightlee/comments/15877.html</wfw:comment><comments>http://www.blogjava.net/Nightlee/articles/15877.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Nightlee/comments/commentRss/15877.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Nightlee/services/trackbacks/15877.html</trackback:ping><description><![CDATA[<TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=ellipse><SPAN class=bvTitle id=subjcns!1p_OQcADDkghdaQH7oYxspUQ!108><STRONG>WebWork之Session</STRONG></SPAN></TD></TR>
<TR>
<TD class=bvh8><STRONG></STRONG></TD></TR>
<TR>
<TD id=msgcns!1p_OQcADDkghdaQH7oYxspUQ!108>
<DIV>由于WebWork对request，parameter，Session和Application都进行了封装，将这些隐含的对象封装成了相应的Map，如RequestMap，ParameterMap，SessionMap和ApplicationMap，而这些Map就组成了ActionContext，因此我们通常都不再需要与request，session这些底层的对象打交道了，这也是我一开始觉得迷惑的地方，因为我找不到Session了。事实上，对于SessionMap的处理即是对Session的处理了。我们可以通过ActionContext的静态方法getContext返回一个ActionContext的实例，然后再调用其getSession方法获得SessionMap，接着就可以利用put和get方法对session进行读写的操作了。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 而在页面上，我们可以通过以下的方式对session进行操作：</DIV>
<DIV>&lt;webwork:property value="#session.name" /&gt;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #session.name表示从SessionMap中取得与"name"这个key对应的对象，实际上是调用了如下的statement：ActionContext.getContext().getSession().get("name")，并且进行了类型的转换。又如：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&lt;webwork:property value="#session.player.name" /&gt;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 则是在SessionMap中获得了Player对象之后，并调用类Player的getter方法：getName()获得name属性。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 简而言之，为了能够降低与部署环境的耦合程度，WebWork将Servlet的隐含对象进行了封装，这在很大程度上简化了开发的工作。而且WebWork也提供了类ServletActionContext，我们通过这个类中的getRequest方法获得原始的HttpServletRequest，然后就可以对request和session这些底层对象进行操作了。但是，一般情况下，利用ActionContext.getSession()可以完成几乎所有的工作了，我们又为什么要去碰那些底层的东西呢？因此我们应该优先考虑使用SessionMap，而不是底层的session。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 另外一个需要注意的问题，就是SessionMap和隐藏对象session的作用域是不同的。也就是说，通过 ActionContext.getContext().getSession().put("name","Fantasy Soft")，往SessionMap中写入了与"name"这个key相对应的内容，但是在页面上通过session.getAttribute("name")得到的将会是null。</DIV></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/Nightlee/aggbug/15877.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Nightlee/" target="_blank">夜来风雨声</a> 2005-10-19 10:45 <a href="http://www.blogjava.net/Nightlee/articles/15877.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>webwork标签库使用技巧</title><link>http://www.blogjava.net/Nightlee/articles/14271.html</link><dc:creator>夜来风雨声</dc:creator><author>夜来风雨声</author><pubDate>Wed, 28 Sep 2005 02:03:00 GMT</pubDate><guid>http://www.blogjava.net/Nightlee/articles/14271.html</guid><wfw:comment>http://www.blogjava.net/Nightlee/comments/14271.html</wfw:comment><comments>http://www.blogjava.net/Nightlee/articles/14271.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Nightlee/comments/commentRss/14271.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Nightlee/services/trackbacks/14271.html</trackback:ping><description><![CDATA[<FONT size=2><STRONG>引用简单对象集合中的元素</STRONG><BR><BR>在循环标签中有这样一种情况</FONT><BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><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">="list"</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>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">OPTION&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="&lt;ww:property/&gt;"</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">ww:property</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">OPTION</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&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><BR><BR><FONT size=2>list是一个String数组，如果在循环中进行if判断，可以这样</FONT><BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><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">="list"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;status</SPAN><SPAN style="COLOR: #0000ff">="rowstatus"</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;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">OPTION&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="&lt;ww:property/&gt;"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;&lt;ww:if&nbsp;test</SPAN><SPAN style="COLOR: #0000ff">="linkFile.inputFilter&nbsp;eq&nbsp;list[#rowstatus.index]"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">selected</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ww:if</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&gt;<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">ww:property&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="list[#rowstatus.index]"</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;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">OPTION</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&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><BR><BR><FONT size=2><STRONG>当嵌套iterator时，如何引用外层的值<BR><BR></STRONG>使用不同的status名称，配合上一条即可<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><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">="contentArray"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;status</SPAN><SPAN style="COLOR: #0000ff">="rowstatus"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">SPAN&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="sp&lt;ww:property&nbsp;value="</SPAN><SPAN style="COLOR: #ff0000">#rowstatus.index"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">"&gt;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">p</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>字段名称<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">INPUT&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="contentArray"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="&lt;ww:property/&gt;"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>字段类型</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">SELECT&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="dataTypeArray"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:iterator&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="dataTypeList"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;status</SPAN><SPAN style="COLOR: #0000ff">="dtstatus"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">OPTION&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="&lt;ww:property&nbsp;value="</SPAN><SPAN style="COLOR: #ff0000">name"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">"&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:if&nbsp;</SPAN><SPAN style="COLOR: #ff0000">test</SPAN><SPAN style="COLOR: #0000ff">="dataTypeArray[#rowstatus.index]&nbsp;eq&nbsp;name"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">selected</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ww:if</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&gt;<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;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ww:property&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="name"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">OPTION</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ww:iterator</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;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">SELECT</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">BUTTON&nbsp;</SPAN><SPAN style="COLOR: #ff0000">onclick</SPAN><SPAN style="COLOR: #0000ff">="sp&lt;ww:property&nbsp;value="</SPAN><SPAN style="COLOR: #ff0000">#rowstatus.index"</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000">.innerHTML=''"&gt;del</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">BUTTON</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:property&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="dataTypeArray[#rowstatus.index]"</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">SPAN</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:iterator</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV></FONT><img src ="http://www.blogjava.net/Nightlee/aggbug/14271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Nightlee/" target="_blank">夜来风雨声</a> 2005-09-28 10:03 <a href="http://www.blogjava.net/Nightlee/articles/14271.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>