<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UKoom &#187; Java</title>
	<atom:link href="http://www.ukoom.com/category/java/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ukoom.com</link>
	<description>Documentum, SharePoint, Alfresco, ECM...</description>
	<lastBuildDate>Thu, 13 May 2010 00:21:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Eclipse SVN Error</title>
		<link>http://www.ukoom.com/eclipse-svn-error.htm</link>
		<comments>http://www.ukoom.com/eclipse-svn-error.htm#comments</comments>
		<pubDate>Wed, 05 May 2010 12:41:58 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1069</guid>
		<description><![CDATA[Error message:
commit -m [...]]]></description>
			<content:encoded><![CDATA[<p>Error message:</p>
<blockquote><p>commit -m &#8220;commit message.&#8221; files<br />
RA layer request failed<br />
svn: Commit failed (details follow):<br />
svn: PROPFIND request failed on &#8216;/repo/path/!svn/vcc/default&#8217;<br />
svn: PROPFIND of &#8216;/repo/path/!svn/vcc/default&#8217;: Could not read status  line: connection was closed by server. (http://example.com)</p>
<p>How to fix?</p>
<p>Looking at my SVN configurations I could only find the JavaHL option, no  SVNKit available.</p></blockquote>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/modifying-jboss-for-enhanced-performance.htm" title="Modifying JBoss for Enhanced Performance">Modifying JBoss for Enhanced Performance</a></li><li><a href="http://www.ukoom.com/powerdesigner-reverse-engineer.htm" title="PowerDesigner Reverse Engineer">PowerDesigner Reverse Engineer</a></li><li><a href="http://www.ukoom.com/gwt-exception-the-style-name-should-be-in-camelcase.htm" title="GWT Exception &#8211; The style name should be in camelCase ">GWT Exception &#8211; The style name should be in camelCase </a></li><li><a href="http://www.ukoom.com/myeclipse-6-5-ga.htm" title="MyEclipse 6.5 GA">MyEclipse 6.5 GA</a></li><li><a href="http://www.ukoom.com/why-csv-files.htm" title="Why CSV files">Why CSV files</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/eclipse-svn-error.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Apache Tomcat 5.5 and IIS 6.0 with JK</title>
		<link>http://www.ukoom.com/install-apache-tomcat-5-5-and-iis-6-0-with-jk.htm</link>
		<comments>http://www.ukoom.com/install-apache-tomcat-5-5-and-iis-6-0-with-jk.htm#comments</comments>
		<pubDate>Tue, 23 Mar 2010 07:57:27 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1053</guid>
		<description><![CDATA[System Requirements
For this [...]]]></description>
			<content:encoded><![CDATA[<p>System Requirements<br />
For this installation I used the following:<br />
Windows Server 2003 Enterprise Edition<br />
Internet Information Services (IIS) 6.0<br />
Sun Java Runtime JRE 5.0 Update 2<br />
Apache Jakarta Tomcat version 5.5.9<br />
The JK Tomcat Web Server Connectors</p>
<p>1.	Install the JDK and Tomcat and set the environment variable.<br />
2.	Configure JK<br />
Download JK from http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.14/isapi_redirect-1.2.14.exe<br />
Setup the file. (It’s better that there isn’t blank space in the directory which you choose to install.)<br />
After installing it, you could find the file “workers.properties.minimal” in \Apache Software Foundation\Jakarta Isapi Redirector, and change its name to “workers.properties”.<br />
Open the Registry Editor; Open the “HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0]”<br />
Change the value “workers.properties.minimal”of worker_file to “workers.properties”<br />
The content of worker.properties and uriworkermap.properties is follow:<br />
worker.properties:<br />
	worker.list=ajp13<br />
	worker.ajp13.type=ajp13<br />
	worker.ajp13.host=localhost<br />
	worker.ajp13.port=8009<br />
uriworkermap.properties:<br />
	# Mapping the URI /admin, /manager, /jsp-examples and /servlets-examples and<br />
	# everything under them to Tomcat<br />
	# /admin/*=ajp3<br />
	# /manager/*=ajp13<br />
	# /jsp-examples/*=ajp13<br />
	# /servlets-examples/*=ajp13</p>
<p>	# Mapping all URI which end with a common suffix .jsp and .do to Tomcat<br />
	# /*.jsp=ajp13<br />
	# /*.do=ajp13</p>
<p>	# Mapping all URI to Tomcat<br />
	/*=ajp13</p>
<p>3.	Create a new website in IIS which point to your website (such as $CATALINA_HOME\ webapps\ROOT)<br />
4.	Configure the Tomcat ISAPI Filter<br />
Rigth click your websitePropertiesISAPI FiltersAddset Filter name “jakarta” and Executable choose the path of “isapi_redirector.dll”OK<br />
Note &#8211; If you check on its status, you may notice that the ISAPI filter hasn’t been successfully loaded at this stage, even if you have re-started IIS. This is expected behaviour and is documented in the IIS6 Operations Guide,<br />
“In an effort to optimize resources in IIS 6.0, an ISAPI filter is not loaded until a request is made to a Web site that requires the ISAPI filter. Until this request is made, IIS Manager does not display the status of the ISAPI filter.”<br />
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/93f23233-2a47-4104-b0b4-a7ec0d3116f3.mspx<br />
However, once IIS has served a successful request to it you will see the status of the ISAPI filter change to ‘Loaded’.<br />
5.	Create a virtual directory for the Tomcat connector to use, create a new Web Service Extension in IIS and then enable that web service extension so that it can be used.<br />
Rigth click your websiteNewVirtual Directoryset Alias: jakartaNextset Path: choose the path of “isapi_redirector.dll”.<br />
6.	Create and exable the tomcat Web Service Extension<br />
Rigth click “Web Service Extension”  Add a new Web service extension Set name: Tomcat, set Required files:choose your “isapi_redirector.dll” click the “Set extension status to Allowed”OK<br />
7.	Add the “.jsp”<br />
Rigth click your websitePropertiesHome DirectoryMappingsAddset Executable: choose your “isapi_redirector.dll”, set Extension:  .jsp (Note: if there is blank space in your path, you need to make your path in Double quotes.)<br />
8.	Set index.jsp as default content page<br />
Rigth click your websitePropertiesDocumentAdd&#8211;&gt;index.jsp<br />
10. Restart tomcat and IIS. You should now be ready to test your Tomcat installation by issuing a request to the sample applications. Visit http://localhost<br />
If show the page as http://localhost:8080, you’re successful.</p>
<p>tomcat5.5 整合 iis6.0<br />
环境：Windows 2003 R2 + IIS 6.0 + JDK 1.5+TOMCAT5.5<br />
1. 安装tomcat</p>
<p>2. 下载jkhttp://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.14/isapi_redirect-1.2.14.exe<br />
安装的好处就是配置文件都有了。只需做少许修改：<br />
安装目录可以随意（最好让目录不带空格），安装完成后在conf里就是它的配置文件，安装完后找到目录文件\Apache Software Foundation\Jakarta Isapi Redirector 这个可以根据你自己的改动，在conf文件里把workers.properties.minimal它改为<br />
workers.properties，对应找到注册表里的<br />
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0] 中的worker_file 点右键修改<br />
同样去掉workers.properties.minimal 后的minimal。</p>
<p>3. 以下为两个文件的内容<br />
	uriworkermap.properties:</p>
<p>	# Mapping the URI /admin, /manager, /jsp-examples and /servlets-examples and<br />
	# everything under them to Tomcat<br />
	# /admin/*=ajp3<br />
	# /manager/*=ajp13<br />
	# /jsp-examples/*=ajp13<br />
	# /servlets-examples/*=ajp13</p>
<p>	# Mapping all URI which end with a common suffix .jsp and .do to Tomcat<br />
	# /*.jsp=ajp13<br />
	# /*.do=ajp13</p>
<p>	# Mapping all URI to Tomcat<br />
	 /*=ajp13</p>
<p>	worker.properties:</p>
<p>	worker.list=ajp13<br />
	worker.ajp13.type=ajp13<br />
	worker.ajp13.host=localhost<br />
	worker.ajp13.port=8009</p>
<p>4. 在iis里新建一个站点，指向网站所在的目录（比如$CATALINA_HOME\webapps\ROOT），然后在站点上点右键选“属性”，在弹出的页框里选择“ISAPI筛选器”，点“添加”，筛选器名称填jakarta,可执行文件中填入你的isapi_redirector.dll的绝对路径。“确定”后点“确定”关闭属性页。再在“默认网站”上右键，选择“新建”－&gt;“虚拟目录”，别名填jakarta，下一步，路径选为你的isapi_redirector.dll存放的目录。</p>
<p>5. 在“Internet信息服务管理器”的“网站”中的“Web服务扩展”上点右键选择“添加一个新的Web服务扩展”，弹出的框中扩展名填Tomcat(其实无所谓的)，“要求的文件”选“添加”然后找到你的isapi_redirector.dll后“确定”。“设置扩展状态为允许”也打上勾，确定。</p>
<p>6. 如果要让iis能读取index.jsp这样的jsp默认首页，还需要在IIS6.0右键单击【默认网站】，选择【属性】，单击【主目录】选项卡中的【配置】，单击【映射】选项卡，单击【添加】，将isapi_redirector.dll的全路径写进去，扩展名要写.jsp（注意：如果你的路径包含空格，那么你需要将这个完整路径用英文的双引号括起来才能添加）。<br />
到这里就配置完了</p>
<p>7. 重起tomcat 重启iis 去掉端口后看看能运行了吧</p>
<p>总结：<br />
    说到底，这就是两种服务的一种集成，使之外部看起来像一种服务，可以这么理解：<br />
外部访问域名－－＞解析后到IP－－＞IIS查找相应站点－－＞发现jsp文件－－＞转至jk连接处理－－＞将相应文件解释转给Tomcat－－＞将页面返回给IIS－－＞展现给客户端。<br />
那么哪出了问题，就查哪，一步一步来，一定能成功的，希望对大家有所帮助，另外多看官方手册，多想其中的原理，网上流传的各种文档不一定就是正确的，包括本文，只是尽量详尽的给一种引导。</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/ways-to-improve-programming-productivity.htm" title="Ways to Improve Programming Productivity">Ways to Improve Programming Productivity</a></li><li><a href="http://www.ukoom.com/link-to-oracle-database.htm" title="Link to Oracle Database">Link to Oracle Database</a></li><li><a href="http://www.ukoom.com/chuck-steak.htm" title="Chuck steak">Chuck steak</a></li><li><a href="http://www.ukoom.com/dm_sysobject_e_not_attachable_type.htm" title="DM_SYSOBJECT_E_NOT_ATTACHABLE_TYPE">DM_SYSOBJECT_E_NOT_ATTACHABLE_TYPE</a></li><li><a href="http://www.ukoom.com/share-files-on-windows-xp.htm" title="Share files on Windows XP">Share files on Windows XP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/install-apache-tomcat-5-5-and-iis-6-0-with-jk.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modifying JBoss for Enhanced Performance</title>
		<link>http://www.ukoom.com/modifying-jboss-for-enhanced-performance.htm</link>
		<comments>http://www.ukoom.com/modifying-jboss-for-enhanced-performance.htm#comments</comments>
		<pubDate>Fri, 26 Feb 2010 08:37:53 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1048</guid>
		<description><![CDATA[The following procedure [...]]]></description>
			<content:encoded><![CDATA[<p><a name="58508">The following procedure is recommended  for enhancing the overall IBM Cognos Now! network performance.</a></p>
<p><a name="58508"><strong>Note: </strong>This procedure requires restarting  the JBoss application server.</a></p>
<h5><a name="58508">Steps</a></h5>
<ol>
<li><a name="58508">In the  \server\default\deploy\jbossweb-tomcat50.sar directory, locate and open the server.xml file.</a></li>
<li><a name="58508">Locate the block listed under the <strong>&lt;!&#8211; A  HTTP/1.1 Connector on port 8080 &#8211;&gt;</strong> heading.</a>
<p><a name="58508"><strong>Note: </strong>The specific port number and other  settings may vary.</a></p>
<p><a name="58508">This block should look like  this:</a></p>
<pre><a name="58508">&lt;!-- A HTTP/1.1 Connector on port 8080 --&gt;</a></pre>
<pre><a name="58508">&lt;Connector port="8080" address="${jboss.bind.address}"</a></pre>
<pre><a name="58508">maxThreads="400" minSpareThreads="100" maxSpareThreads="75"</a></pre>
<pre><a name="58508">enableLookups="false" redirectPort="8443" acceptCount="100"</a></pre>
<pre><a name="58508">connectionTimeout="20000" disableUploadTimeout="true"/&gt;</a></pre>
</li>
<li><a name="58508">Add the following parameters:</a>
<pre><a name="58508">compression="on" </a></pre>
<pre><a name="58508">socketBuffer="1045576" /&gt;</a></pre>
</li>
<li><a name="58508">Save and close the server.xml file.</a></li>
<li><a name="58508">Restart JBoss.</a></li>
</ol>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/eclipse-svn-error.htm" title="Eclipse SVN Error">Eclipse SVN Error</a></li><li><a href="http://www.ukoom.com/powerdesigner-reverse-engineer.htm" title="PowerDesigner Reverse Engineer">PowerDesigner Reverse Engineer</a></li><li><a href="http://www.ukoom.com/gwt-exception-the-style-name-should-be-in-camelcase.htm" title="GWT Exception &#8211; The style name should be in camelCase ">GWT Exception &#8211; The style name should be in camelCase </a></li><li><a href="http://www.ukoom.com/myeclipse-6-5-ga.htm" title="MyEclipse 6.5 GA">MyEclipse 6.5 GA</a></li><li><a href="http://www.ukoom.com/why-csv-files.htm" title="Why CSV files">Why CSV files</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/modifying-jboss-for-enhanced-performance.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerDesigner Reverse Engineer</title>
		<link>http://www.ukoom.com/powerdesigner-reverse-engineer.htm</link>
		<comments>http://www.ukoom.com/powerdesigner-reverse-engineer.htm#comments</comments>
		<pubDate>Fri, 05 Feb 2010 05:34:06 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1040</guid>
		<description><![CDATA[Get the Physical [...]]]></description>
			<content:encoded><![CDATA[<p>Get the Physical Data Model<br />
1. Menu Operation<br />
File, Reverse Engineer , Database, New Phycial Data Model<br />
2. Connection<br />
Add a connect to the target database<br />
3. Choose tables to generate the models</p>
<p>Generate the Java Code<br />
1. Menu Operation<br />
Tools , Generate Object-Oriented Model, Detail, O/R Mapping,<br />
Enable Transformations, Extended Model Definitions, O/R Mapping,      Hibernate</p>
<p>To be continued.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/hibernate-lost-timezone-when-getting-timestamp-from-oracle.htm" title="Hibernate lost timezone when getting timestamp from Oracle">Hibernate lost timezone when getting timestamp from Oracle</a></li><li><a href="http://www.ukoom.com/eclipse-svn-error.htm" title="Eclipse SVN Error">Eclipse SVN Error</a></li><li><a href="http://www.ukoom.com/get-definition-for-view-in-oracle.htm" title="Get definition for view in Oracle">Get definition for view in Oracle</a></li><li><a href="http://www.ukoom.com/modifying-jboss-for-enhanced-performance.htm" title="Modifying JBoss for Enhanced Performance">Modifying JBoss for Enhanced Performance</a></li><li><a href="http://www.ukoom.com/powerdesigner-non-sqlerror.htm" title="PowerDesigner Non SQLError">PowerDesigner Non SQLError</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/powerdesigner-reverse-engineer.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts2 Result Type</title>
		<link>http://www.ukoom.com/struts2-result-type.htm</link>
		<comments>http://www.ukoom.com/struts2-result-type.htm#comments</comments>
		<pubDate>Wed, 20 Jan 2010 13:58:09 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1020</guid>
		<description><![CDATA[Result Types are [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Result Types</strong> are classes that determine what happens after an Action executes and a Result is returned. Developers are free to create their own Result Types according to the needs of their application or environment. In WebWork 2 for example, Servlet and Velocity Result Types have been created to handle rendering views in web applications.</p>
<p><ins>Note:</ins> All built in webwork result types implement the <tt>com.opensymphony.xwork.Result</tt> interface, which represents a generic interface for all action execution results, whether that be displaying a webpage, generating an email, sending a JMS message, etc.</p>
<p>Result types define classes and map them to names to be referred in the action configuration results. This serves as a shorthand name-value pair for these classes.</p>
<div id="blog_text">
<div>一个提交到服务器的处理通常可以分为两个阶段，第一个阶段查询服务器状态（查询或者更新数据库），第二个阶段选择一个合适的结果页面其返回给用户（这里要讲的Result的内容）。</div>
<div>Struts2提供了对不同种类返回结果的支持，常见的有JSP，FreeMarker，Velocity等。</div>
<div>Struts2支持的不同类型的返回结果为：</div>
<table style="border: medium none ; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border: 1pt solid black; padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 113.3pt;" width="151" valign="top">
<div><strong>名字</strong></div>
</td>
<td style="padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 274.2pt;" width="366" valign="top">
<div><strong>说明</strong></div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Chain Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>用来处理Action链</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Dispatcher Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>用来转向页面，通常处理JSP</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>FreeMarker Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>处理FreeMarker模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>HttpHeader Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>用来控制特殊的Http行为</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Redirect Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>重定向到一个URL</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Redirect Action Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>重定向到一个Action</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Stream Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>向浏览器发送InputSream对象，通常用来处理文件下载</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>Velocity Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>处理Velocity模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>XLS Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>处理XML/XLST模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>PlainText Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>显示原始文件内容，例如文件源代码</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt;" width="151" valign="top">
<div>S2PLUGINS:Tiles Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt;" width="366" valign="top">
<div>结合Tile使用</div>
</td>
</tr>
</tbody>
</table>
<div>另外第三方的Result类型还包括JasperReports Plugin，专门用来处理JasperReport类型的报表输出。</div>
<div>在struts-default.xml文件中已经有了对于所有类型Result的定义：</div>
<div>&lt;result-types&gt;</div>
<div><span>&lt;result-type name=&#8221;chain&#8221;</span></div>
<div><span>class=&#8221;com.opensymphony.xwork2.ActionChainResult&#8221;/&gt;</span></div>
<div><strong><span>&lt;result-type name=&#8221;dispatcher&#8221;</span></strong></div>
<div><strong><span>class=&#8221;org.apache.struts2.dispatcher.ServletDispatcherResult&#8221;</span></strong></div>
<div><strong><span>default=&#8221;true&#8221;/&gt;</span></strong></div>
<div><span>&lt;result-type name=&#8221;freemarker&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.freemarker.FreemarkerResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;httpheader&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.HttpHeaderResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirectAction&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;stream&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.StreamResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;velocity&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.VelocityResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;xslt&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.xslt.XSLTResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plainText&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div><span>&lt;!&#8211; Deprecated name form scheduled for removal in Struts 2.1.0.</span></div>
<div><span>The camelCase versions are preferred. See ww-1707 &#8211;&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect-action&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plaintext&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div>&lt;/result-types&gt;</div>
<div>
<p>从上述代码中可以看出在不指定Result类型的时候使用dispatcher类型。</p></div>
<div>定义一个Result值，</div>
<div>&lt;result name=&#8221;success&#8221; type=&#8221;dispatcher&#8221;&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>&lt;/result&gt;</div>
<div>由于type默认值是dispatcher，所以这里不需要定义，另外name的默认值为success所以这里也不需要定义。</div>
<div>上述代码可以简写为：</div>
<div>&lt;result&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>
<p>&lt;/result&gt;</p></div>
<div>另外location参数也可以直接卸载result标签内部，所以上述代码的最简单的写法为：</div>
<div>&lt;result&gt;/ThankYou.jsp&lt;/result&gt;</div>
<div>我们也可以定义多个不同的Result</div>
<div>&lt;action name=&#8221;Hello&#8221;&gt;</div>
<div>&lt;result&gt;/hello/Result.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/hello/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;input&#8221;&gt;/hello/Input.jsp&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div>上述代码的含义为，名字为Hello的Action有三个返回结果，并且都是dispatcher类型（默认类型），这三个返回值的名字分别为 success（默认值），error，input，对应的页面的路径分别为/hello/Result.jsp，/hello/Error.jsp， /hello/Input.jsp。</div>
<div>有些时候我们需要一个定义在全局的Result，这个时候我们可以在package内部定义全局的Result，例如：</div>
<div>&lt;global-results&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;invalid.token&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;login&#8221; type=&#8221;redirect-action&#8221;&gt;Logon!input&lt;/result&gt;</div>
<div>
<p>&lt;/global-results&gt;</p></div>
<div><strong>动态返回结果</strong></div>
<div>有些时候，只有当Action执行完璧的时候我们才知道要返回哪个结果，这个时候我们可以在Action内部定义一个属性，这个属性用来存储Action执行完璧之后的Result值，例如：</div>
<div>private String nextAction;</div>
<div>public String getNextAction() {</div>
<div><span>return nextAction;</span></div>
<div>}</div>
<div>在strutx.xml配置文件中，我们可以使用${nextAction}来引用到Action中的属性，通过${nextAction}表示的内容来动态的返回结果，例如：</div>
<div>&lt;action name=&#8221;fragment&#8221;&gt;</div>
<div>&lt;result name=&#8221;next&#8221; type=&#8221;redirect-action&#8221;&gt;${nextAction}&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div>上述Action的execute方法返回next的时候，还需要根据nextAction的属性来判断具体定位到哪个Action。</div>
<div>如果想转发到另外个action可以设置type=chain 同时结果不加shtml</div>
</div>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/freemarker-result.htm" title="FreeMarker Result">FreeMarker Result</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/struts2-result-type.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeMarker Result</title>
		<link>http://www.ukoom.com/freemarker-result.htm</link>
		<comments>http://www.ukoom.com/freemarker-result.htm#comments</comments>
		<pubDate>Wed, 20 Jan 2010 13:55:04 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1018</guid>
		<description><![CDATA[Renders a view [...]]]></description>
			<content:encoded><![CDATA[<p>Renders a view using the Freemarker template engine.</p>
<p>The FreemarkarManager class configures the template loaders so that the template location can be either</p>
<ul>
<li>relative to the web root folder. eg <code>/WEB-INF/views/home.ftl</code></li>
<li>a classpath resuorce. eg <code>/com/company/web/views/home.ftl</code></li>
</ul>
<p>Parameters</p>
<p>* location (default) &#8211; the location of the template to process.</p>
<p>* parse &#8211; true by default. If set to false, the location param will not be parsed for Ognl expressions.</p>
<p>* contentType &#8211; defaults to &#8220;text/html&#8221; unless specified.</p>
<p>* writeIfCompleted &#8211; false by default, write to stream only if there isn&#8217;t any error processing the template. Setting template_exception_handler=rethrow in freemarker.properties will have the same effect.</p>
<p>Examples</p>
<pre><span>&lt;result name=<span>"success"</span> type=<span>"freemarker"</span>&gt;</span>foo.ftl<span>&lt;/result&gt;

Of course, we can also omit the 'type' setting by setting the result type
of struts. Please refer to another article of this site - Struts result type.

</span></pre>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 337px; width: 1px; height: 1px;">
<div id="blog_text" class="cnt">
<div>一个提交到服务器的处理通常可以分为两个阶段，第一个阶段查询服务器状态（查询或者更新数据库），第二个阶段选择一个合适的结果页面其返回给用户（这里要讲的Result的内容）。</div>
<div></div>
<div>Struts2提供了对不同种类返回结果的支持，常见的有JSP，FreeMarker，Velocity等。</div>
<div>Struts2支持的不同类型的返回结果为：</div>
<table style="border: medium none ; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border: 1pt solid black; padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 113.3pt;" width="151" valign="top">
<div><strong>名字</strong></div>
</td>
<td style="padding: 0cm 5.4pt; background: #bfbfbf none repeat scroll 0% 0%; width: 274.2pt; border: 1pt 1pt 1pt medium solid solid solid none -moz-use-text-color;" width="366" valign="top">
<div><strong>说明</strong></div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Chain Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>用来处理Action链</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Dispatcher Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>用来转向页面，通常处理JSP</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>FreeMarker Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>处理FreeMarker模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>HttpHeader Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>用来控制特殊的Http行为</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Redirect Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>重定向到一个URL</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Redirect Action Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>重定向到一个Action</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Stream Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>向浏览器发送InputSream对象，通常用来处理文件下载</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>Velocity Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>处理Velocity模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>XLS Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>处理XML/XLST模板</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>PlainText Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>显示原始文件内容，例如文件源代码</div>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 113.3pt; border: medium 1pt 1pt none solid solid -moz-use-text-color;" width="151" valign="top">
<div>S2PLUGINS:Tiles Result</div>
</td>
<td style="padding: 0cm 5.4pt; width: 274.2pt; border: medium 1pt 1pt medium none solid solid none -moz-use-text-color;" width="366" valign="top">
<div>结合Tile使用</div>
</td>
</tr>
</tbody>
</table>
<div>另外第三方的Result类型还包括JasperReports Plugin，专门用来处理JasperReport类型的报表输出。</div>
<div></div>
<div>在struts-default.xml文件中已经有了对于所有类型Result的定义：</div>
<div>&lt;result-types&gt;</div>
<div><span>&lt;result-type name=&#8221;chain&#8221;</span></div>
<div><span>class=&#8221;com.opensymphony.xwork2.ActionChainResult&#8221;/&gt;</span></div>
<div><strong><span>&lt;result-type name=&#8221;dispatcher&#8221;</span></strong></div>
<div><strong><span>class=&#8221;org.apache.struts2.dispatcher.ServletDispatcherResult&#8221;</span></strong></div>
<div><strong><span>default=&#8221;true&#8221;/&gt;</span></strong></div>
<div><span>&lt;result-type name=&#8221;freemarker&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.freemarker.FreemarkerResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;httpheader&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.HttpHeaderResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirectAction&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;stream&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.StreamResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;velocity&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.VelocityResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;xslt&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.views.xslt.XSLTResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plainText&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div><span>&lt;!&#8211; Deprecated name form scheduled for removal in Struts 2.1.0.</span></div>
<div><span>The camelCase versions are preferred. See ww-1707 &#8211;&gt;</span></div>
<div><span>&lt;result-type name=&#8221;redirect-action&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.ServletActionRedirectResult&#8221;/&gt;</span></div>
<div><span>&lt;result-type name=&#8221;plaintext&#8221;</span></div>
<div><span>class=&#8221;org.apache.struts2.dispatcher.PlainTextResult&#8221; /&gt;</span></div>
<div>&lt;/result-types&gt;</div>
<div></div>
<div>
<p>从上述代码中可以看出在不指定Result类型的时候使用dispatcher类型。</p></div>
<div></div>
<div>定义一个Result值，</div>
<div>&lt;result name=&#8221;success&#8221; type=&#8221;dispatcher&#8221;&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>&lt;/result&gt;</div>
<div>由于type默认值是dispatcher，所以这里不需要定义，另外name的默认值为success所以这里也不需要定义。</div>
<div>上述代码可以简写为：</div>
<div>&lt;result&gt;</div>
<div><span>&lt;param name=&#8221;location&#8221;&gt;/ThankYou.jsp&lt;/param&gt;</span></div>
<div>
<p>&lt;/result&gt;</p></div>
<div>另外location参数也可以直接卸载result标签内部，所以上述代码的最简单的写法为：</div>
<div>&lt;result&gt;/ThankYou.jsp&lt;/result&gt;</div>
<div></div>
<div>我们也可以定义多个不同的Result</div>
<div>&lt;action name=&#8221;Hello&#8221;&gt;</div>
<div>&lt;result&gt;/hello/Result.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/hello/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;input&#8221;&gt;/hello/Input.jsp&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div>上述代码的含义为，名字为Hello的Action有三个返回结果，并且都是dispatcher类型（默认类型），这三个返回值的名字分别为 success（默认值），error，input，对应的页面的路径分别为/hello/Result.jsp，/hello/Error.jsp， /hello/Input.jsp。</div>
<div></div>
<div>有些时候我们需要一个定义在全局的Result，这个时候我们可以在package内部定义全局的Result，例如：</div>
<div>&lt;global-results&gt;</div>
<div>&lt;result name=&#8221;error&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;invalid.token&#8221;&gt;/Error.jsp&lt;/result&gt;</div>
<div>&lt;result name=&#8221;login&#8221; type=&#8221;redirect-action&#8221;&gt;Logon!input&lt;/result&gt;</div>
<div>
<p>&lt;/global-results&gt;</p></div>
<div></div>
<div><strong>动态返回结果</strong></div>
<div>有些时候，只有当Action执行完璧的时候我们才知道要返回哪个结果，这个时候我们可以在Action内部定义一个属性，这个属性用来存储Action执行完璧之后的Result值，例如：</div>
<div>private String nextAction;</div>
<div></div>
<div>public String getNextAction() {</div>
<div><span>return nextAction;</span></div>
<div>}</div>
<div></div>
<div>在strutx.xml配置文件中，我们可以使用${nextAction}来引用到Action中的属性，通过${nextAction}表示的内容来动态的返回结果，例如：</div>
<div>&lt;action name=&#8221;fragment&#8221; class=&#8221;FragmentAction&#8221;&gt;</div>
<div>&lt;result name=&#8221;next&#8221; type=&#8221;redirect-action&#8221;&gt;${nextAction}&lt;/result&gt;</div>
<div>&lt;/action&gt;</div>
<div></div>
<div>上述Action的execute方法返回next的时候，还需要根据nextAction的属性来判断具体定位到哪个Action。</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>如果想转发到另外个action可以设置type=chain 同时结果不加shtml</div>
</div>
</div>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/struts2-result-type.htm" title="Struts2 Result Type">Struts2 Result Type</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/freemarker-result.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GET POST 区别详解</title>
		<link>http://www.ukoom.com/get-post-%e5%8c%ba%e5%88%ab%e8%af%a6%e8%a7%a3.htm</link>
		<comments>http://www.ukoom.com/get-post-%e5%8c%ba%e5%88%ab%e8%af%a6%e8%a7%a3.htm#comments</comments>
		<pubDate>Wed, 13 Jan 2010 07:13:24 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Web MVC]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1010</guid>
		<description><![CDATA[1、Get是用来从服务器上获得数据，而Post是用来向服务器上传递数据。
2、Get将表单中数据的按照variable=value的形式，添加到action所指向的URL后面，并且两者使用“?”连接，而各个变量之间使用“&#38;”连接；Post是将表单中的数据放在form的数据体中，按照变量和值相对应的方式，传递到action所指向URL。
3、Get是不安全的，因为在传输过程，数据被放在请求的URL中，而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中，然后放在某个地方，这样就可能会有一些隐私的信息被第三方看到。另外，用户也可以在浏览器上直接看到提交的数据，一些系统内部消息将会一同显示在用户面前。Post的所有操作对用户来说都是不可见的。
4、Get传输的数据量小，这主要是因为受URL长度限制；而Post可以传输大量的数据，所以在上传文件只能使用Post（当然还有一个原因，将在后面的提到）。
5、Get限制Form表单的数据集的值必须为ASCII字符；而Post支持整个ISO10646字符集。默认是用ISO-8859-1编码
6、Get是Form的默认方法。
以下的比较非常非常使用：
做java的web开发有段日子了，有个问题老是困扰着我，就是乱码问题，基本上是网上查找解决方案（网上资料真的很多），都是一大堆的介绍如何解决此类的乱码问题，但是没几个把问题的来龙去脉说清楚的，有时候看了些文章后，以为自己懂了，但是在开发中乱码问题又像鬼魂一样出来吓人，真是头大了！这篇文章是我长时间和乱码做斗争的一些理解的积累，还希望有更多的朋友给出指点和补充。
  form有2中方法把数据提交给服务器，get和post,分别说下吧。
（一）get提交
 [...]]]></description>
			<content:encoded><![CDATA[<p>1、Get是用来从服务器上获得数据，而Post是用来向服务器上传递数据。<br />
2、Get将表单中数据的按照variable=value的形式，添加到action所指向的URL后面，并且两者使用“?”连接，而各个变量之间使用“&amp;”连接；Post是将表单中的数据放在form的数据体中，按照变量和值相对应的方式，传递到action所指向URL。<br />
3、Get是不安全的，因为在传输过程，数据被放在请求的URL中，而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中，然后放在某个地方，这样就可能会有一些隐私的信息被第三方看到。另外，用户也可以在浏览器上直接看到提交的数据，一些系统内部消息将会一同显示在用户面前。Post的所有操作对用户来说都是不可见的。<br />
4、Get传输的数据量小，这主要是因为受URL长度限制；而Post可以传输大量的数据，所以在上传文件只能使用Post（当然还有一个原因，将在后面的提到）。<br />
5、Get限制Form表单的数据集的值必须为ASCII字符；而Post支持整个ISO10646字符集。默认是用ISO-8859-1编码<br />
6、Get是Form的默认方法。<br />
以下的比较非常非常使用：<br />
做java的web开发有段日子了，有个问题老是困扰着我，就是乱码问题，基本上是网上查找解决方案（网上资料真的很多），都是一大堆的介绍如何解决此类的乱码问题，但是没几个把问题的来龙去脉说清楚的，有时候看了些文章后，以为自己懂了，但是在开发中乱码问题又像鬼魂一样出来吓人，真是头大了！这篇文章是我长时间和乱码做斗争的一些理解的积累，还希望有更多的朋友给出指点和补充。<br />
  form有2中方法把数据提交给服务器，get和post,分别说下吧。<br />
（一）get提交<br />
  1.首先说下客户端（浏览器）的form表单用get方法是如何将数据编码后提交给服务器端的吧。 </p>
<p>    对于get方法来说，都是把数据串联在请求的url后面作为参数，如：http://localhost:8080/servlet?msg=abc<br />
（很常见的一个乱码问题就要出现了，如果url中出现中文或其它特殊字符的话，如：http://localhost:8080 /servlet?msg=杭州，服务器端容易得到乱码），url拼接完成后，浏览器会对url进行URL encode，然后发送给服务器，URL encode的过程就是把部分url做为字符，按照某种编码方式（如：utf-8,gbk等）编码成二进制的字节码，然后每个字节用一个包含3个字符的字符串 &#8220;%xy&#8221; 表示，其中xy为该字节的两位十六进制表示形式。我这里说的可能不清楚，具体介绍可以看下java.net.URLEncoder类的介绍在这里。了解了 URL encode的过程，我们能看到2个很重要的问题，第一：需要URL encode的字符一般都是非ASCII的字符（笼统的讲），再通俗的讲就是除了英文字母以外的文字（如：中文，日文等）都要进行URL encode，所以对于我们来说，都是英文字母的url不会出现服务器得到乱码问题，出现乱码都是url里面带了中文或特殊字符造成的；第二：URL encode到底按照那种编码方式对字符编码？这里就是浏览器的事情了，而且不同的浏览器有不同的做法，中文版的浏览器一般会默认的使用GBK，通过设置浏览器也可以使用UTF-8，可能不同的用户就有不同的浏览器设置，也就造成不同的编码方式，所以很多网站的做法都是先把url里面的中文或特殊字符用 javascript做URL encode，然后再拼接url提交数据，也就是替浏览器做了URL encode，好处就是网站可以统一get方法提交数据的编码方式。 完成了URL encode，那么现在的url就成了ASCII范围内的字符了，然后以iso-8859-1的编码方式转换成二进制随着请求头一起发送出去。这里想多说几句的是，对于get方法来说，没有请求实体，含有数据的url都在请求头里面，之所以用URL encode，我个人觉的原因是：对于请求头来说最终都是要用iso-8859-1编码方式编码成二进制的101010&#8230;..的纯数据在互联网上传送，如果直接将含有中文等特殊字符做iso-8859-1编码会丢失信息，所以先做URL encode是有必要的。<br />
   2。服务器端（tomcat）是如何将数据获取到进行解码的。<br />
   第一步是先把数据用iso-8859-1进行解码，对于get方法来说，tomcat获取数据的是ASCII范围内的请求头字符，其中的请求url里面带有参数数据，如果参数中有中文等特殊字符，那么目前还是URL encode后的%XY状态，先停下，我们先说下开发人员一般获取数据的过程。通常大家都是request.getParameter(&#8221;name&#8221;)获取参数数据，我们在request对象或得的数据都是经过解码过的，而解码过程中程序里是无法指定，这里要说下，有很多新手说用 request.setCharacterEncoding(&#8221;字符集&#8221;)可以指定解码方式，其实是不可以的，看servlet的官方API说明有对此方法的解释：Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().可以看出对于get方法他是无能为力的。那么到底用什么编码方式解码数据的呢，这是tomcat的事情了，默认缺省用的是 iso-8859-1,这样我们就能找到为什么get请求带中文参数为什么在服务器端得到乱码了，原因是在客户端一般都是用UTF-8或GBK对数据 URL encode，这里用iso-8859-1方式URL decoder显然不行，在程序里我们可以直接<br />
Java代码<br />
1. new String(request.getParameter(&#8221;name&#8221;).getBytes(&#8221;iso-8859-1&#8243;),&#8221;客户端指定的URL encode编码方式&#8221;)<br />
还原回字节码，然后用正确的方式解码数据，网上的文章通常是在tomcat里面做个配置<br />
Xml代码<br />
1.<br />
这样是让tomcat在获取数据后用指定的方式URL decoder，URL decoder的介绍在这里<br />
（一）post提交<br />
1.客户端（浏览器）的form表单用post方法是如何将数据编码后提交给服务器端的。<br />
  在post方法里所要传送的数据也要URL encode，那么他是用什么编码方式的呢？<br />
   在form所在的html文件里如果有段，那么post就会用此处指定的编码方式编码。一般大家都认为这段代码是为了让浏览器知道用什么字符集来对网页解释，所以网站都会把它放在html代码的最前端，尽量不出现乱码，其实它还有个作用就是指定form表单的post方法提交数据的 URL encode编码方式。从这里可以看出对于get方法来数，浏览器对数据的URL encode的编码方式是有浏览器设置来决定，（可以用js做统一指定），而post方法，开发人员可以指定。<br />
2。服务器端（tomcat）是如何将数据获取到进行解码的。<br />
如果用tomcat默认缺省设置，也没做过滤器等编码设置，那么他也是用iso-8859-1解码的，但是request.setCharacterEncoding(&#8221;字符集&#8221;)可以派上用场。 </p>
<p>我发现上面说的tomcat所做的事情前提都是在请求头里没有指定编码方式，如果请求头里指定了编码方式将按照这种方式编码。<br />
   有2篇文章推荐下，地址分别是<br />
深入浅出URL编码：http://www.cnblogs.com/yencain/articles/1321386.html；<br />
表单用post方法提交数据时乱码问题：http://wanghuan8086.javaeye.com/blog/173869 </p>
<p>用post很重要的在form所在的html文件里如果有段<br />
强烈建议使用post提交</p>
<p>详细出处参考：http://www.jb51.net/web/12714.html<br />
http://www.cnblogs.com/hyddd/archive/2009/03/31/1426026.html</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/dm_query_e_table_no_access.htm" title="DM_QUERY_E_TABLE_NO_ACCESS">DM_QUERY_E_TABLE_NO_ACCESS</a></li><li><a href="http://www.ukoom.com/chown-change-the-owner-of-a-file.htm" title="chown &#8211; change the owner of a file">chown &#8211; change the owner of a file</a></li><li><a href="http://www.ukoom.com/backup-repository-by-oracle-tools.htm" title="Backup repository by oracle tools">Backup repository by oracle tools</a></li><li><a href="http://www.ukoom.com/my-favorite-films.htm" title="My favorite films">My favorite films</a></li><li><a href="http://www.ukoom.com/install-lifecycle.htm" title="Install and Uninstall Lifecycle">Install and Uninstall Lifecycle</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/get-post-%e5%8c%ba%e5%88%ab%e8%af%a6%e8%a7%a3.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlazeDS factory mechanism</title>
		<link>http://www.ukoom.com/blazeds-factory-mechanism.htm</link>
		<comments>http://www.ukoom.com/blazeds-factory-mechanism.htm#comments</comments>
		<pubDate>Wed, 23 Dec 2009 09:05:17 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=988</guid>
		<description><![CDATA[BlazeDS provides a [...]]]></description>
			<content:encoded><![CDATA[<p>BlazeDS provides a factory mechanism that lets you plug in your own component creation and maintenance system to allow it to integrate with systems like EJB and Spring, which store components in their own namespace. You provide a class that implements the flex.messaging.FlexFactory interface. This class is used to create a FactoryInstance that corresponds to a component configured for a specific destination.</p>
<p>Remoting Service destinations use Java classes that you write to integrate with Flex clients. By default, BlazeDS creates these instances. If they are application-scoped components, they are stored in the ServletContext attribute space using the destination&#8217;s name as the attribute name. If you use session-scoped components, the components are stored in the FlexSession, also using the destination name as the attribute. If you specify an <samp>attribute-id</samp> element in the destination, you can control which attribute the component is stored in; this lets more than one destination share the same instance.</p>
<p>The following examples shows a destination definition that contains an <samp>attribute-id</samp> element:</p>
<pre>&lt;destination id="WeatherService"&gt;
    &lt;properties&gt;
        &lt;source&gt;weather.WeatherService&lt;/source&gt;
        &lt;scope&gt;application&lt;/scope&gt;
        &lt;attribute-id&gt;MyWeatherService&lt;/attribute-id&gt;
    &lt;/properties&gt;
&lt;/destination&gt;</pre>
<p>In this example, BlazeDS creates an instance of the class weather.WeatherService and stores it in the ServletContext object&#8217;s set of attributes with the name MyWeatherService. If you define a different destination with the same <samp>attribute-id</samp> value and the same Java class, BlazeDS uses the same component instance.</p>
<p>BlazeDS provides a factory mechanism that lets you plug in your own component creation and maintenance system to BlazeDS so it integrates with systems like EJB and Spring, which store components in their own namespace. You provide a class that implements the flex.messaging.FlexFactory interface. You use this class to create a FactoryInstance that corresponds to a component configured for a specific destination. Then the component uses the FactoryInstance to look up the specific component to use for a given request. The FlexFactory implementation can access configuration attributes from a BlazeDS configuration file and also can access FlexSession and ServletContext objects. For more information, see the documentation for the FlexFactory class in the public BlazeDS Javadoc documentation.</p>
<p>After you implement a FlexFactory class, you can configure it to be available to destinations by placing a <samp>factory</samp> element in the <samp>factories</samp> element in the services-config.xml file, as the following example shows. A single FlexFactory instance is created for each BlazeDS web application. This instance can have its own configuration properties, although in this example, there are no required properties to configure the factory.</p>
<pre>&lt;factories&gt;
    &lt;factory id="spring"/&gt;
&lt;/factories&gt;</pre>
<p>BlazeDS creates one FlexFactory instance for each <samp>factory</samp> element that you specify. BlazeDS uses this one global FlexFactory implementation for each destination that specifies that factory by its ID; the ID is identified by using a <samp>factory</samp> element in the <samp>properties</samp> section of the destination definition. For example, your remoting-config.xml file could have a destination similar to the following one:</p>
<pre>&lt;destination id="WeatherService"&gt;
    &lt;properties&gt;
        &lt;factory&gt;spring&lt;/factory&gt;
        &lt;source&gt;weatherBean&lt;/source&gt;
    &lt;/properties&gt;
&lt;/destination&gt;</pre>
<p>When the <samp>factory</samp> element is encountered at start up, BlazeDS calls the <samp>FlexFactory.createFactoryInstance()</samp> method. That method gets the <samp>source</samp> value and any other attributes it expects in the configuration. Any attributes that you access from the ConfigMap parameter are marked as expected and do not cause a configuration error, so you can extend the default BlazeDS configuration in this manner. When BlazeDS requires an instance of the component for this destination, it calls the <samp>FactoryInstance.lookup()</samp> method to retrieve the individual instance for the destination.</p>
<p>Optionally, factory instances can take additional attributes. There are two places you can do this. When you define the factory initially, you can provide extra attributes as part of the factory definition. When you define an instance of that factory, you can also add your own attributes to the destination definition to be used in creating the factory instance.</p>
<p>The boldface text in the following example shows an attribute added to the factory definition:</p>
<pre>&lt;factories&gt;
    &lt;factory id="myFactoryId"&gt;
        &lt;properties&gt;
<strong><samp>            &lt;myfactoryattributename&gt;</samp></strong>
<strong><samp>                myfactoryattributevalue</samp></strong>
<strong><samp>            &lt;/myfactoryattributename&gt;</samp></strong>
        &lt;/properties&gt;
    &lt;/factory&gt;
&lt;/factories&gt;</pre>
<p>You could use this type of configuration when you are integrating with the Spring Framework Java application framework to provide the Spring factory with a default path for initializing the Spring context that you use to look up all components for that factory. In the class that implements FlexFactory, you would include a call to retrieve the values of the <samp>myfactoryattributename</samp> from the <samp>configMap</samp> parameter to the <samp>initialize()</samp> method in the FlexFactory interface, as the following example shows:</p>
<pre>public void initialize(String id, ConfigMap configMap){
    System.out.println("**** MyFactory initialized with: " +
        configMap.getPropertyAsString("myfactoryattributename", "not set"));
}</pre>
<p>The <samp>initialize()</samp> method in the previous example retrieves a string value where the first parameter is the name of the attribute, and the second parameter is the default value to use if that value is not set. For more information about the various calls to retrieve properties in the config map, see the documentation for the flex.messaging.config.ConfigMap class in the public BlazeDS Javadoc documentation. Each factory instance can add configuration attributes that are used when that factory instance is defined, as the following example shows:</p>
<pre>&lt;destination id="myDestination"&gt;
    &lt;properties&gt;
        &lt;source&gt;mypackage.MyRemoteClass&lt;/source&gt;
        &lt;factory&gt;myFactoryId&lt;/factory&gt;
        &lt;myfactoryinstanceattribute&gt;
            myfoobar2value
        &lt;/myfactoryinstanceattribute&gt;
    &lt;/properties&gt;
&lt;/destination&gt;</pre>
<p>In the <samp>createFactoryInstance()</samp> method as part of the FlexFactory implementation, you access the attribute for that instance of the factory, as the following example shows:</p>
<pre>public FactoryInstance createFactoryInstance(String id, ConfigMap properties) {
    System.out.println("**** MyFactoryInstance instance initialized with myfactoryinstanceattribute=" +
    properties.getPropertyAsString("myfactoryinstanceattribute", "not set"));
….
}

All these info are from http://livedocs.adobe.com/blazeds/1/blazeds_devguide</pre>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm" title="Flex LC DS FDS and BlazeDS">Flex LC DS FDS and BlazeDS</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/blazeds-factory-mechanism.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex LC DS FDS and BlazeDS</title>
		<link>http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm</link>
		<comments>http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:04:26 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Web MVC]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=976</guid>
		<description><![CDATA[* Flex 1.0 [...]]]></description>
			<content:encoded><![CDATA[<p>* Flex 1.0 (includes the SDK and Server) – Released March 2004</p>
<p>* Flex 1.5  – Released Nov 2004</p>
<p>* FDS (Flex Data Services) was decoupled from the Flex SDK in Flex 2.0 – Released 2006</p>
<p>* FDS was renamed LiveCycle Data Services – released as LC DS 2.5 in summer 2007</p>
<p>* LC DS 2.5.1 in fall 2007</p>
<p>* An open source version of remoting and messaging was released as Blaze DS in early 2008</p>
<p>* LC DS 2.6 was released in mid 2008</p>
<p>* LC DS 2.6.1 was released in Nov 2008</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/blazeds-factory-mechanism.htm" title="BlazeDS factory mechanism">BlazeDS factory mechanism</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/flex-lc-ds-fds-and-blazeds.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>$wnd and $doc Calling native JavaScript with JSNI</title>
		<link>http://www.ukoom.com/wnd-and-doc-calling-native-javascript-with-jsni.htm</link>
		<comments>http://www.ukoom.com/wnd-and-doc-calling-native-javascript-with-jsni.htm#comments</comments>
		<pubDate>Tue, 15 Dec 2009 02:18:07 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[GWT]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=964</guid>
		<description><![CDATA[$wnd 是什么？
GWT provides the $wnd and $doc variables to refer to the window and document objects
GWT使用通过Java Native method使用它，声明一个native方法，将含有JavaScript的方法体注释。编译器将注释块内的内容逐字输出，使之与编译产生的JavaScript整合到一起。]]></description>
			<content:encoded><![CDATA[<p>$wnd and $doc Calling native JavaScript with JSNI</p>
<p>$wnd 是什么？</p>
<p>GWT provides the $wnd and $doc variables to refer to the window and document objects</p>
<p>GWT使用通过Java Native method使用它，声明一个native方法，将含有JavaScript的方法体注释。编译器将注释块内的内容逐字输出，使之与编译产生的JavaScript整合到一起。</p>
<p>Java调用JavaScript方法：</p>
<p>JSNI方法定义需要使用native关键字，并且需要在参数列表之后，结尾的分号之前定义。JSNI方法的开始使用 /*-{ , 结尾使用}-*/,例如：</p>
<p>public static native void alert(String msg) /*-{</p>
<p>         $wnd.alert(msg);</p>
<p>}-*/;</p>
<p>这是gwt  Window 类中的源码&#8211;一个标准的jsni 方法, 我们可以看到,方法实现就是一行简单的javascript 代码. (这里没有用 alert 或者 window.alert 的原因是: gwt 代码运行在一个iframe中,如果直接用alert或者window.alert,引用的是iframe文档,而不是host page 文档). 经过这个方法包装,以后在gwt程序中使用 &#8221; Window.alert&#8221;  实际上就是调用了javascript 的 alert 方法,当然你也可以不用这个封装, 直接实用 $wnd.alert .</p>
<p>当上述方法在Java中调用的时候，实际上将调用Window的alert()方法，将传入的内容打印出来。在Hosted Mode下，断点可以调协在上述方法中，可以查看传入的参数。</p>
<p>参考如下：</p>
<p><a href="http://www.javaeye.com/topic/365678">http://www.javaeye.com/topic/365678</a></p>
<p><a href="http://www.webreference.com/programming/java/toolkits/">http://www.webreference.com/programming/java/toolkits/</a></p>
<p>The GWT makes ingenious use of Java&#8217;s native methods with something called the JavaScript Native Interface. You declare native methods with commented-out bodies that contain JavaScript. When those native methods are compiled, the GWT incorporates the commented JavaScript. Here&#8217;s an example of such a native method:</p>
<p>Calling native JavaScript with JSNI</p>
<p><a href="http://www.ibm.com/developerworks/java/library/j-ajax4/">http://www.ibm.com/developerworks/java/library/j-ajax4/</a></p>
<p>Visual-effects libraries are becoming increasingly popular in Web application development, whether their effects are used to provide subtle user-interaction cues or just to add polish. I&#8217;d like to add some eye-candy to the Weather Reporter application. GWT doesn&#8217;t provide this type of functionality, but its JavaScript Native Interface (JSNI) offers a solution. JSNI lets you make JavaScript calls directly from GWT client Java code. This means that I can exploit effects from the Scriptaculous library (see Resources) or from the Yahoo! User Interface library, for example.</p>
<p>JSNI uses a cunning combination of the Java language&#8217;s native keyword and JavaScript embedded in a special comment block. It&#8217;s probably best explained by example, so Listing 10 shows a method that invokes a given Scriptaculous effect on an Element:</p>
<p>Listing 10. Invoking Scriptaculous effects with JSNI</p>
<p> private native void applyEffect(Element element, String effectName) /*-{</p>
<p>   // Trigger named Scriptaculous effect<br />
   $wnd.Effect[effectName](element);<br />
}-*/;</p>
<p>This is perfectly valid Java code because the compiler sees only private native void applyEffect(Element element, String effectName);. GWT parses the contents of the comment block and outputs the JavaScript verbatim. GWT provides the $wnd and $doc variables to refer to the window and document objects. In this case, I&#8217;m simply accessing the top-level Scriptaculous Effect object and using JavaScript&#8217;s square-bracket object-accessor syntax to invoke the named function specified by the caller. The Element type is a &#8220;magic&#8221; type provided by GWT that represents a Widget&#8217;s underlying HTML DOM element in both Java and JavaScript code. Strings are one of the few other types that can be passed transparently between Java code and JavaScript via JSNI.</p>
<p>Now I have a weather report that fades in nicely when the data is returned from the server. The final touch is to re-enable the ZIP code TextBox when the effect has finished. Scriptaculous uses an asynchronous callback mechanism to notify listeners about the life cycle of effects. This is where things get a little more complex because I need to have JavaScript call back into my GWT client Java code. In JavaScript, you can invoke any function with an arbitrary number of arguments, so Java-style method overloading doesn&#8217;t exist. This means that JSNI needs to use an unwieldy syntax to refer to Java methods to disambiguate possible overloads. The GWT documentation states this syntax as:</p>
<p>[instance-expr.]@class-name::method-name(param-signature)(arguments)<br />
 <br />
The instance-expr. part is optional because static methods are invoked without the need for an object reference.</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.ukoom.com/smart-gwt-faq.htm" title="Smart GWT FAQ">Smart GWT FAQ</a></li><li><a href="http://www.ukoom.com/gwt-and-documentum.htm" title="GWT and Documentum">GWT and Documentum</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/wnd-and-doc-calling-native-javascript-with-jsni.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
