??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品成人久久久,密臀av在线播放,国产91精品一区二区http://www.aygfsteel.com/lanluquan/category/14512.htmllanluquanzh-cnThu, 19 Jul 2007 02:58:24 GMTThu, 19 Jul 2007 02:58:24 GMT60Javascript cookie操作ȝhttp://www.aygfsteel.com/lanluquan/articles/131040.html旱头憨脑旱头憨脑Wed, 18 Jul 2007 05:26:00 GMThttp://www.aygfsteel.com/lanluquan/articles/131040.htmlhttp://www.aygfsteel.com/lanluquan/comments/131040.htmlhttp://www.aygfsteel.com/lanluquan/articles/131040.html#Feedback0http://www.aygfsteel.com/lanluquan/comments/commentRss/131040.htmlhttp://www.aygfsteel.com/lanluquan/services/trackbacks/131040.htmlZ在Cookie中解军_Wؕ码问题,在保存Cookie前对ValueD行编码,可以由服务器后台写入CookieQ也可以在Browser端用Javascript写入?br>以下是在Browser端通过Javascript操作CookieQ(均ؓ|络转蝲Q?/p>

构造通用的cookie处理函数Q?br>1Q添加一个cookieQaddCookie(name,value,expireHours)
该函数接?个参敎ͼcookie名称Qcookie|以及在多小时后q期。这里约定expireHours?时不讑֮q期旉Q即当浏览器关闭时cookie自动消失。该函数实现如下Q?br>

<script language="JavaScript" type="text/javascript">
<!--
function addCookie(name,value,expireHours){
var cookieString=name+"="+escape(value);
//判断是否讄q期旉
if(expireHours>0){
var date=new Date();
date.setTime(date.getTime
+expireHours*3600*1000); // 转换为毫U?/span>
cookieString=cookieString+"; expire="+date.toGMTString();
}

document.cookie
=cookieString;
}

//-->
</script>


2Q获取指定名U的cookie|getCookie(name)
该函数返回名UCؓname的cookie|如果不存在则q回I,其实现如下:

<script language="JavaScript" type="text/javascript">
<!--
function getCookie(name){
var strCookie=document.cookie;
var arrCookie=strCookie.split(""); // 多cookie切割为多个名/值对
for(var i=0;i<arrCookie.length;i++)// 遍历cookie数组Q处理每个cookie?/span>
var arr=arrCookie[i].split("="); // 扑ֈ名称为userId的cookieQƈq回它的?/span>
if(arr[0]==name)
return arr[1];
}

return "";
}

//-->
</script>


3Q删除指定名U的cookieQdeleteCookie(name)
该函数可以删除指定名U的cookieQ其实现如下Q?br>

<script language="JavaScript" type="text/javascript">
<!--
function deleteCookie(name){
var date=new Date();
date.setTime(date.getTime()
-10000); // 删除一个cookieQ就是将其过期时间设定ؓ一个过ȝ旉
document.cookie=name+"=v; expire="+date.toGMTString();
}

//-->
</script> 


旱头憨脑 2007-07-18 13:26 发表评论
]]>
Spring2.0 AOP 心得Q二Q?/title><link>http://www.aygfsteel.com/lanluquan/articles/76366.html</link><dc:creator>旱头憨脑</dc:creator><author>旱头憨脑</author><pubDate>Fri, 20 Oct 2006 05:10:00 GMT</pubDate><guid>http://www.aygfsteel.com/lanluquan/articles/76366.html</guid><wfw:comment>http://www.aygfsteel.com/lanluquan/comments/76366.html</wfw:comment><comments>http://www.aygfsteel.com/lanluquan/articles/76366.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/lanluquan/comments/commentRss/76366.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/lanluquan/services/trackbacks/76366.html</trackback:ping><description><![CDATA[      l上文,在实C对Service层的AOP后,我决定用同样的方法去攚w我的Spring controller层和Interceptor。发现controller层根本没有成功,而Interceptor的AOP只能出现在单元测试中Q放在服务器上跑又是不成功。也许Spring的AOP只能对POJOq行AOPQ而对非POJO的,如servlet{是不行的。这个问题要攑ֈ以后再学习和解决?img src ="http://www.aygfsteel.com/lanluquan/aggbug/76366.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/lanluquan/" target="_blank">旱头憨脑</a> 2006-10-20 13:10 <a href="http://www.aygfsteel.com/lanluquan/articles/76366.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring2.0 AOP使用心得Q一Q?/title><link>http://www.aygfsteel.com/lanluquan/articles/76341.html</link><dc:creator>旱头憨脑</dc:creator><author>旱头憨脑</author><pubDate>Fri, 20 Oct 2006 03:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/lanluquan/articles/76341.html</guid><wfw:comment>http://www.aygfsteel.com/lanluquan/comments/76341.html</wfw:comment><comments>http://www.aygfsteel.com/lanluquan/articles/76341.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/lanluquan/comments/commentRss/76341.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/lanluquan/services/trackbacks/76341.html</trackback:ping><description><![CDATA[      正在做的目中有一个类似积分的需求,比如用户在讨论区发帖后,需要给一定的U分q样的需求。因为需求是变化的,同时Z使已l写好的发帖代码不被入RQ所以考虑使用Spring2.0 AOP来实现这个功能?br />      毕竟是第一ơ用Spring2.0的AOPQ按照Reference中的介绍Q准备用Annotation来完成对AOP的配|。来看一下我做的步骤Q?br />      一、需要用Spring2.0的jar包,现在已经发布正式版的2.0了,可以?a >http://www.springframework.org/</a>  上下载到最新的2.0版本。加入到目的classpath中去?br />      二、需要在配置文g中启用新的spring2.0的schema或者是dtd。  ?br />      1、在Spring的xml配置文g中加入新的schemaQ?<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.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">beans </span><span style="COLOR: #ff0000">xmlns</span><span style="COLOR: #0000ff">="http://www.springframework.org/schema/beans"</span><span style="COLOR: #ff0000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:xsi</span><span style="COLOR: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="COLOR: #ff0000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:aop</span><span style="COLOR: #0000ff">="http://www.springframework.org/schema/aop"</span><span style="COLOR: #ff0000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:tx</span><span style="COLOR: #0000ff">="http://www.springframework.org/schema/tx"</span><span style="COLOR: #ff0000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xsi:schemaLocation</span><span style="COLOR: #0000ff">="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"</span><span style="COLOR: #ff0000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    default-autowire</span><span style="COLOR: #0000ff">="byName"</span><span style="COLOR: #ff0000"> default-lazy-init</span><span style="COLOR: #0000ff">="true"</span><span style="COLOR: #0000ff">></span></div>       2、“如果用Java 5的话Q推荐用Spring提供的@AspectJ切面支持Q通过q种方式声明Spring AOP中用的切面?"@AspectJ"使用了Java 5的注解,可以切面声明ؓ普通的JavacR”——Spring reference<br />      3、ؓ了用AOP的AnnotationQ在配置文g中加?lt;aop:aspectj-autoproxy />?br />      4、编写切面类Q?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.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">@Aspect<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> ArticleRemoteAccountsService </span><span id="Codehighlighter1_100_1203_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img id="Codehighlighter1_381_530_Open_Image" onclick="this.style.display='none'; Codehighlighter1_381_530_Open_Text.style.display='none'; Codehighlighter1_381_530_Closed_Image.style.display='inline'; Codehighlighter1_381_530_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_381_530_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_381_530_Closed_Text.style.display='none'; Codehighlighter1_381_530_Open_Image.style.display='inline'; Codehighlighter1_381_530_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_381_530_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_381_530_Open_Text"><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />     * 在发帖成功之后,l用户银币̎户冲?br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />     * <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />     * </span><span style="COLOR: #808080">@param</span><span style="COLOR: #008000"> arg<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />     * </span><span style="COLOR: #808080">@throws</span><span style="COLOR: #008000"> AccountsException<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />     * </span><span style="COLOR: #808080">@throws</span><span style="COLOR: #008000"> InstantiationException<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />     * </span><span style="COLOR: #808080">@throws</span><span style="COLOR: #008000"> IllegalAccessException<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />     </span><span style="COLOR: #008000">*/</span></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    @After(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">execution(* com.company.ArticleManager.saveArticle(..))</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> && args(arg)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> exSilByPost(Article arg) </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> AccountsException,<br /><img id="Codehighlighter1_746_1200_Open_Image" onclick="this.style.display='none'; Codehighlighter1_746_1200_Open_Text.style.display='none'; Codehighlighter1_746_1200_Closed_Image.style.display='inline'; Codehighlighter1_746_1200_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_746_1200_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_746_1200_Closed_Text.style.display='none'; Codehighlighter1_746_1200_Open_Image.style.display='inline'; Codehighlighter1_746_1200_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            InstantiationException, IllegalAccessException </span><span id="Codehighlighter1_746_1200_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.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_746_1200_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (arg.getLastUpdateTime() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> arg.getArticleByParentId() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"><br /><img id="Codehighlighter1_870_968_Open_Image" onclick="this.style.display='none'; Codehighlighter1_870_968_Open_Text.style.display='none'; Codehighlighter1_870_968_Closed_Image.style.display='inline'; Codehighlighter1_870_968_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_870_968_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_870_968_Closed_Text.style.display='none'; Codehighlighter1_870_968_Open_Image.style.display='inline'; Codehighlighter1_870_968_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> arg.getArticleByRootId() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_870_968_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.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_870_968_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> TODO 主题?/span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (arg.getLastUpdateTime() </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> (arg.getArticleByParentId() </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">||</span><span style="COLOR: #000000"> arg<br /><img id="Codehighlighter1_1099_1196_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1099_1196_Open_Text.style.display='none'; Codehighlighter1_1099_1196_Closed_Image.style.display='inline'; Codehighlighter1_1099_1196_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1099_1196_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1099_1196_Closed_Text.style.display='none'; Codehighlighter1_1099_1196_Open_Image.style.display='inline'; Codehighlighter1_1099_1196_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                        .getArticleByRootId() </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">)) </span><span id="Codehighlighter1_1099_1196_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.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_1099_1196_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> TODO  回帖</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div>q里需要注意的是用Annotation的Poincut语法Q?br />execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern) <span id="wmqeeuq" class="code-keyword">throws</span>-pattern?)<br />q里׃累诉了?br />同时要注意的如何得到参数的问题,写法参考如上?img src ="http://www.aygfsteel.com/lanluquan/aggbug/76341.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/lanluquan/" target="_blank">旱头憨脑</a> 2006-10-20 11:02 <a href="http://www.aygfsteel.com/lanluquan/articles/76341.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat中,UTF-8 URL提交参数中文解决l极Ҏhttp://www.aygfsteel.com/lanluquan/articles/74541.html旱头憨脑旱头憨脑Wed, 11 Oct 2006 06:21:00 GMThttp://www.aygfsteel.com/lanluquan/articles/74541.htmlhttp://www.aygfsteel.com/lanluquan/comments/74541.htmlhttp://www.aygfsteel.com/lanluquan/articles/74541.html#Feedback0http://www.aygfsteel.com/lanluquan/comments/commentRss/74541.htmlhttp://www.aygfsteel.com/lanluquan/services/trackbacks/74541.html       ׃上情况分析,应该是在传输q程中丢׃某个字符Q因为我们知道在传输中是?q制形式传输?br />       于是可以在JSP面上,在提交URL之前Q用javascript的encodeURIComponent()来将参数~码成ؓUNICODEQ之后在服务器端使用URLDecoder.decodeq行解码?br />        果然Q解决问题。不q这U方式实在太不优雅?img src ="http://www.aygfsteel.com/lanluquan/aggbug/74541.html" width = "1" height = "1" />

旱头憨脑 2006-10-11 14:21 发表评论
]]>
Struts中不限个C传文件的实现Ҏhttp://www.aygfsteel.com/lanluquan/articles/67051.html旱头憨脑旱头憨脑Fri, 01 Sep 2006 03:38:00 GMThttp://www.aygfsteel.com/lanluquan/articles/67051.htmlhttp://www.aygfsteel.com/lanluquan/comments/67051.htmlhttp://www.aygfsteel.com/lanluquan/articles/67051.html#Feedback0http://www.aygfsteel.com/lanluquan/comments/commentRss/67051.htmlhttp://www.aygfsteel.com/lanluquan/services/trackbacks/67051.html      首先Q在Jsp面中,需要有?63那样动态添加附件的功能Q这个可以用JS来实现。代码如下:
       
                                            <tr bgcolor="#FFFFFF">
                                                
<td nowrap id="fileTD" align="center" colSpan="2">
                                                    
<input name="uploadFile(0)" type="file" size="40">
                                                    
<input type="button" onclick="addFile()" value="d"/>
                                                
</td>
                                            
</tr>

    var fileIndex = 0;
    
function addFile() 
    
{
        fileIndex
++;
        
var spanId = "fileTD";
        
var fileId = "uploadFile(" +fileIndex+ ")";
        addInputFile(spanId, fileId);
    }

    
function addInputFile(spanId, fileId) 
    
{
        
var span = document.getElementById(spanId);
        
if (span != null
        
{
            
var divObj = document.createElement("div");
            
var fileObj, delObj;
            divObj.id 
= fileId;
               fileObj 
= document.createElement("<input type=file>");
               delObj 
= document.createElement("<input type=button onclick=delInputFile('" + spanId + "','" + fileId + "')>");
            fileObj.name 
= fileId;
            fileObj.size 
= "40";
            fileObj.className = "input";
            delObj.value 
='删除';
            divObj.appendChild(fileObj);
            divObj.appendChild(document.createTextNode(
" "));
            divObj.appendChild(delObj);
            span.appendChild(divObj);
        }

    }

    
function delInputFile(spanId, fileId) 
    
{
        
var span = document.getElementById(spanId);
        
var divObj = document.getElementById(fileId);
        
if (span != null && divObj != null
        
{
            span.removeChild(divObj);
        }

    }

上面代码中的Html和JS代码可以实现动态添加行的效果。(上述JS代码参考了一位网友的实现Q这里对他表C感谢。)
Html代码中的 <input name="uploadFile(0)" type="file" size="40">Ҏ让hqhQ我也是W一ơ写 name="uploadFile(0)"q样的Html代码?/span>
q里?font color="#0000ff">uploadFile(0)表示数组中index=0的元素,那么在Struts的FormBean中又应该如何让BeanUtils在做反射的时候可以正的赋值呢Q?br />来看一下FormBean中的代码Q?br />
import java.util.ArrayList;

import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;

public class BulletinInfoForm extends ActionForm {
    
private static final long serialVersionUID = -7869342360944575352L;

    
private Long id;
    
    
private String newsTitle;
    
    
private String newsType;
    
    
private String newsContent;

    
private ArrayList<FormFile> uploadFiles = new ArrayList<FormFile>();

    
public void setUploadFile(String index, FormFile formFile) {
        
this.uploadFiles.add(formFile);
    }


    
public ArrayList<FormFile> getUploadFiles() {
        
return this.uploadFiles;
    }


    
public Long getId() {
        
return id;
    }


    
public void setId(Long id) {
        
this.id = id;
    }


    
public String getNewsContent() {
        
return newsContent;
    }


    
public void setNewsContent(String newsContent) {
        
this.newsContent = newsContent;
    }


    
public String getNewsTitle() {
        
return newsTitle;
    }


    
public void setNewsTitle(String newsTitle) {
        
this.newsTitle = newsTitle;
    }


    
public String getNewsType() {
        
return newsType;
    }


    
public void setNewsType(String newsType) {
        
this.newsType = newsType;
    }


    
}

留意以上代码中的
public void setUploadFile(String index, FormFile formFile) {
        
this.uploadFiles.add(formFile);
    }


q里提供的setUploadFIle(String index, FormFile formFile)其实是lBeanUtils一个正的借口Q让它可以对uploadFile(0)q样的元素进行正的反射。当Ӟq里不用考虑indexQ直接将formFiledqlist中?br />
      因此Q在Struts中不限个C传文件的实现中,主要是页面中动态添加上传文件行和在FormBean中正赋|Action中要做的怿很单了Q只要把FormBean中的List取出来逐个q行操作?br />      

旱头憨脑 2006-09-01 11:38 发表评论
]]>
Spring2.0 新特性之Bean新增范围session, request, global sessionhttp://www.aygfsteel.com/lanluquan/articles/66222.html旱头憨脑旱头憨脑Mon, 28 Aug 2006 09:07:00 GMThttp://www.aygfsteel.com/lanluquan/articles/66222.htmlhttp://www.aygfsteel.com/lanluquan/comments/66222.htmlhttp://www.aygfsteel.com/lanluquan/articles/66222.html#Feedback0http://www.aygfsteel.com/lanluquan/comments/commentRss/66222.htmlhttp://www.aygfsteel.com/lanluquan/services/trackbacks/66222.html      Spring2.0之前Q我们是q么定义的:
      <bean id="singletonBean" class="myBean.singletonBean" />
      
<bean id="notSingletonBean" class="myBean.notSingletonBean" singleton="false"/>

      在Spring2.0以后Q因为增加了session, request, global session三种Bean的范_所以在Bean的配|上Q也发生了改变,不过Bean的默认范围仍然是singleton?br />       新的写法如下Q?br />
<bean id="newBean" class="myBean.newBean" scope="session | request | global session | singleton | prototype">
<aop:scoped-proxy/>
</bean>

       对于新增加的三种范围QSpring2.0对Bean的要求就是必L在web环境中才能定义这三种范围。对比之前的singletoBean和notSingletonBean的XML定义Q我们可以发?font color="#000000"><aop:scoped-proxy/> q个新的配置V?br />      那么Q这又是怎么一回事呢?
      Z理解Z么需要这一行和以前完全不同的Bean配置Q我们需要对Spring2.0实现session, request, global session三种Bean的范围的原理q行研究?br />      可以惌Q对于开发h员来_最重要的是得到一个实例,该实例提供给我们的就是和我们需要的Bean一L接口。无论我们定义的Bean的范围如何,容器都要求可以将正确的实例返回给我们Q那么,采用代理机制则可以完成这一个Q务。代理机制屏蔽了ZBean所定义的范围返回实例的要求Q同时可以提供和我们所要求的Bean同样的接的口。基于这个原理,
Z实现Z作用域机制的Bean的控ӞSpring2.0引入了一个新的接口:
public interface Scope {
 Object get(String name, ObjectFactory objectFactory);

 Object remove(String name);
}
 

      q个接口是用来表CBean范围的接口,而在ConfigurableBeanFactory接口中定义了Bean工厂相关Scope注册的方法,使得可往Bean工厂中加入新范围的Bean?br />
public interface ConfigurableBeanFactory extends HierarchicalBeanFactory,
 
void registerScope(String scopeName, Scope scope);
 void destroyScopedBean(String beanName);
}

      同时QSpring2.0在AbstractFactoryBean的getBeanҎ中实C对Scope Bean支持以及在WebApplicationContext中注册session.request,global session三种ScopeQ这里就不l脓代码了?br />      最后需要提醒的是global session是应用于Zportlet的web应用中才有意义?/font>


旱头憨脑 2006-08-28 17:07 发表评论
]]>
վ֩ģ壺 ƽ| | κ| | ˳| ľ| ϼ| | | | | | | | | ߰| ˷| ̨| | | ͭ| | ˮ| | | Ϫ| ³ƶ| | | | | ľ| | ¡| | | Ǹ| ½| IJ| Ű| ʲ|