﻿<?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-kingmove-文章分类-Struts</title><link>http://www.blogjava.net/kingmove/category/18679.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 06 May 2008 23:57:14 GMT</lastBuildDate><pubDate>Tue, 06 May 2008 23:57:14 GMT</pubDate><ttl>60</ttl><item><title>学习struts的一些体会</title><link>http://www.blogjava.net/kingmove/articles/198387.html</link><dc:creator>KingMove</dc:creator><author>KingMove</author><pubDate>Mon, 05 May 2008 03:38:00 GMT</pubDate><guid>http://www.blogjava.net/kingmove/articles/198387.html</guid><wfw:comment>http://www.blogjava.net/kingmove/comments/198387.html</wfw:comment><comments>http://www.blogjava.net/kingmove/articles/198387.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kingmove/comments/commentRss/198387.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kingmove/services/trackbacks/198387.html</trackback:ping><description><![CDATA[1.添加ERRORS时需用到资源文----》errors.add("key required",<br />
new ActionMessage("key.required"));<br />
<br />
2.使用SaveErrors()函数需 import ActionMessages类（struts1.2下，struts1.1下为ActionErrorso类）<br />
<br />
3.配置Validator时，是将form bean的type设为org.apache.struts.validator.DynaValidatorForm，若是DynaActionForm则将属性dynamic设为true。<br />
<br />
4.将显示中文的资源文件用native2ascii工具转换后即可使用，页面不会显示乱码，无须写程序设置filter属性。（也不知是不是我的操作系统太强了，其他人的这样似乎是不行的）<br />
<br />
5.&lt;html:link&gt;的使用--------利用action属性传递动态参数。若是单个参数可用paramName,paramProperty,paramID属性，若是多参数则用name,property属性(此处的property返回的应是Map类型，此Map类型记录了多个参数的值)<br />
如：&lt;html:link action="/searchAction.do?pageMethod=previous" name="pager" property="map" &gt;上一页&lt;/html:link&gt;其中map 须是在pager Bearn中声明为Map类型。 假设map中有参数（currentsPage=&#8221;1&#8221;,key=&#8221;name&#8221;）,则浏览页面显示为&lt;a href=&#8221;/ searchAction.do?pageMethod=previous&amp;currentsPage=1&amp;key=&#8221;name&#8221;&gt;上一面&lt;/a&gt;<br />
<br />
如：&lt;html:link action="/searchAction.do?pageMethod=previous" paramName="pager" paramProperty="currentPage" paramId=&#8221;currentPage&#8221; &gt;上一页&lt;/html:link&gt;其中paramProperty标明的是参数名称，paramId 标明的是参数的值为pager Bearn中currentPage的值。假设pager中currentPager的值为1，则浏览页面显示为&lt;a href=&#8221;/ searchAction.do?pageMethod=previous&amp;currentsPage=1&gt;上一面&lt;/a&gt;<br />
<br />
6．&lt;% //在action中&nbsp;&nbsp;&nbsp;&nbsp; java.util.HashMap pms = new java.util.HashMap();&nbsp;&nbsp;&nbsp; pms.put("username", "qianqian");&nbsp;&nbsp;&nbsp; pms.put("***", "female");&nbsp;&nbsp;&nbsp; request.setAttribute("params", pms); %&gt; &lt;html:link action="/test.do" name="params" &gt;test&lt;/html:link&gt; 编译后的结果：&lt;a href="/test.do?username=qianqian&amp;***=female"&gt;test&lt;/a&gt;<br />
<br />
7. String from=request.getParameter("from");<br />
&nbsp;&nbsp; if("ctrl".equals(from)) {}//此处不用from.equals(&#8220;ctrl&#8221;),i否则from为null时会出错。<br />
8．Action连续执行两次的问题。<br />
一般是由于JSP页面中用到了&lt;img&gt;标签，且其引用地址为空时，程序默认将当前地址作为其引用地址，故JSP页面相当于提交了两次，从而导致Action执行了两次。
<img src ="http://www.blogjava.net/kingmove/aggbug/198387.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kingmove/" target="_blank">KingMove</a> 2008-05-05 11:38 <a href="http://www.blogjava.net/kingmove/articles/198387.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts标签设置的变量在哪里取？</title><link>http://www.blogjava.net/kingmove/articles/198384.html</link><dc:creator>KingMove</dc:creator><author>KingMove</author><pubDate>Mon, 05 May 2008 03:36:00 GMT</pubDate><guid>http://www.blogjava.net/kingmove/articles/198384.html</guid><wfw:comment>http://www.blogjava.net/kingmove/comments/198384.html</wfw:comment><comments>http://www.blogjava.net/kingmove/articles/198384.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kingmove/comments/commentRss/198384.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kingmove/services/trackbacks/198384.html</trackback:ping><description><![CDATA[有时需要用到脚本去取struts标签里设置的值，如&lt;logic:iterator id="data" property="dataList"&gt;&lt;/logic:iterator&gt;这里struts标签就设置了变量data，这个data的值可以用脚本这样取到：&lt;%pageContext.findAttribute("data")%&gt;(前提是标签的scope属性设置为默认值"page"，)
<img src ="http://www.blogjava.net/kingmove/aggbug/198384.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kingmove/" target="_blank">KingMove</a> 2008-05-05 11:36 <a href="http://www.blogjava.net/kingmove/articles/198384.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>optionsCollection的用法</title><link>http://www.blogjava.net/kingmove/articles/89812.html</link><dc:creator>KingMove</dc:creator><author>KingMove</author><pubDate>Mon, 25 Dec 2006 01:09:00 GMT</pubDate><guid>http://www.blogjava.net/kingmove/articles/89812.html</guid><wfw:comment>http://www.blogjava.net/kingmove/comments/89812.html</wfw:comment><comments>http://www.blogjava.net/kingmove/articles/89812.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kingmove/comments/commentRss/89812.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kingmove/services/trackbacks/89812.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">方法一：<br /><br />Jsp</span>
				<span style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">中：<span lang="EN-US"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;html:select property="resultEx" &gt;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<span style="mso-tab-count: 1">    </span>&lt;html:optionsCollection name="requestNums"/&gt;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;/html:select&gt;<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Bean</span>
				<span style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">中：<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">List&lt;LabelValueBean&gt; nums=</span>
				<b>
						<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">new</span>
				</b>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">ArrayList&lt;LabelValueBean&gt;();</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">    </span>
						<span style="mso-tab-count: 1">
						</span>
				</span>
				<b>
						<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">for</span>
				</b>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">(Short i=1;i&lt;=29;i++){</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">    </span>
						<span style="mso-tab-count: 2">     </span>nums.add(</span>
				<b>
						<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">new</span>
				</b>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">LabelValueBean(SysUtil.<i>trimBall</i>(i,</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">""</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">),i+</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">""</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">));</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">    </span>}</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						<span style="mso-spacerun: yes">    </span>
						<span style="mso-tab-count: 1">
						</span>
				</span>
				<b>
						<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">this</span>
				</b>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">.</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #0000c0; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">req</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">.setAttribute(</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">"requestNums"</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">, nums);</span>
		</p>
<img src ="http://www.blogjava.net/kingmove/aggbug/89812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kingmove/" target="_blank">KingMove</a> 2006-12-25 09:09 <a href="http://www.blogjava.net/kingmove/articles/89812.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>