﻿<?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-&lt;font color="red"&gt;JRen&lt;/font&gt;&lt;font color="lightgreen"&gt;大鹏一曰同风起，扶摇直上九万里&lt;/font&gt;-随笔分类-Struts</title><link>http://www.blogjava.net/liaojiyong/category/11436.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 16 May 2007 07:36:47 GMT</lastBuildDate><pubDate>Wed, 16 May 2007 07:36:47 GMT</pubDate><ttl>60</ttl><item><title>Struts ActionForm的优化写法（转）</title><link>http://www.blogjava.net/liaojiyong/archive/2007/05/16/117833.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Wed, 16 May 2007 06:25:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2007/05/16/117833.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/117833.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2007/05/16/117833.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/117833.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/117833.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 要点：&nbsp; 在ActionForm定义值对象company，定义Setter/Getter方法；&nbsp; 在JSP里对input元素的名称稍加变化，加company前缀，company.cp_name。&nbsp; Struts能把company.cp_name的值自动地Populate到对象company，填充cp_name属性。效果：&nbsp; 简化ActionForm对属性...&nbsp;&nbsp;<a href='http://www.blogjava.net/liaojiyong/archive/2007/05/16/117833.html'>阅读全文</a><img src ="http://www.blogjava.net/liaojiyong/aggbug/117833.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2007-05-16 14:25 <a href="http://www.blogjava.net/liaojiyong/archive/2007/05/16/117833.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tiles-struts(转)</title><link>http://www.blogjava.net/liaojiyong/archive/2007/03/26/106309.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Mon, 26 Mar 2007 01:38:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2007/03/26/106309.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/106309.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2007/03/26/106309.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/106309.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/106309.html</trackback:ping><description><![CDATA[ypically during Web application development, the user interface (UI) group creates the site's look and feel. Based on that look and feel, the group creates HTML pages that represent the application's functionality and navigation. With a servlets and <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>Server Pages (JSPs)-based implementation, where HTML pages are converted into servlets and JSPs, UI developers identify common HTML and JSP view components, such as header, footer, body, menu, and search. This article presents various solutions to effectively and efficiently organize HTML and JSP view components. I evaluate each solution using specific criteria, such as page number, code repetition, and layout control. 
<p>To e<a title="" href="http://www.xgdown.com/article/44/ArticleList44_1.htm" target="_blank">XP</a>lore templating and layout solutions, we will use the Tiles framework. The Tiles framework's view components are known as <em>tiles</em>. The framework uses an <a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> configuration file to organize those tiles. This framework not only enables you to reuse tiles, but also the layouts that organize them. 
</p><p>To e<a title="" href="http://www.xgdown.com/article/44/ArticleList44_1.htm" target="_blank">XP</a>lore the more powerful and flexible solutions, we will investigate the synergy between the Tiles and Struts frameworks. Struts is an open source framework for developing Web applications using the popular Model-View-Controller (MVC) or Model 2 architectural pattern. Struts comes with a large set of reusable tags for which the Tiles tag library makes an <a title="" href="http://www.xgdown.com/article/294/ArticleList294_1.htm" target="_blank">Excel</a>lent enhancement. 
</p><p><font size="+1"><strong>Evaluation criteria </strong></font><br />I will evaluate each solution based on the criteria below. The criteria are not mutually exclusive. For a specific situation and particular application, you must always balance between the strengths and weaknesses of each solution with respect to these factors. 
</p><p><strong>Page number </strong><br />A solution should strive to minimize the number of HTML and JSP pages. As the page number increases, the complexity of developing, managing, and maintaining an application increases drastically. 
</p><p><strong>Code repetition </strong><br />Under most circumstances, repetition is bad. The more repeated HTML and JSP code, the more difficult it is to develop and maintain an application. A simple change can result in a cascade of changes in many different pages with unpredictable consequences. A concrete and practical way of attaining reuse is to avoid code repetition. 
</p><p><strong>Layout control </strong><br />While code repetition is bad, repetition of layout logic and code can be worse. Spreading the logic and behavior of view component organization over several JSPs can be a recipe for disaster. Attaining reuse of templating and layout logic is a better form of reuse than only reusing view components. Thus, you can achieve a higher level of reuse with effective layout control. 
</p><p><strong>Coupling </strong><br />Coupling is the degree of interactivity between entities. Software engineers are taught again and again to minimize coupling between unrelated classes, packages, and so on. We can apply the same principle to view components. Even though there are distinct view components from a user perspective, in the JSP implementation, the components might be intricately coupled. A solution should reduce coupling between unrelated view components. 
</p><p><strong>Complexity </strong><br />Complexity brings increased development and maintenance costs, making a more complex solution less suitable. Complexity grows fast as well, and what might originally look simple and innocuous can quickly turn into a big mess as you add more pieces. 
</p><p><font size="+1"><strong>Solutions </strong></font><br />I'll evaluate several solutions using a basic example of JSPs with common view components, like header and footer. I'll present these solutions in order of increasing complexity, and then I'll measure in detail each one against the evaluation criteria. 
</p><p><strong>Solution 1: Basic JSP </strong><br />Consider the following JSP for <code>a.jsp</code>: <code><p>&lt;html&gt;<br /><br />&lt;body&gt;<br /><br />Header<br />&lt;p&gt;<br /><br />a's body...<br />&lt;p&gt;<br /><br />Footer <br />&lt;p&gt;<br /><br />&lt;/body&gt;<br /><br />&lt;/html&gt;<br /><br /></p></code></p><p>Consider the following JSP for <code>b.jsp</code>: <code><p>&lt;html&gt;<br /><br />&lt;body&gt;<br /><br />Header<br />&lt;p&gt; <br /><br />b's body... <br />&lt;p&gt;<br /><br />Footer <br />&lt;p&gt;<br /><br />&lt;/body&gt;<br /><br />&lt;/html&gt;<br /><br /></p></code></p><p>In many cases, the developers obtain the code from the UI group and literally convert it into a JSP as necessary. As shown above, each JSP has a duplicate header and footer. Solution 1 is undesirable because changes in common view components, like header and footer, require changes in all relevant pages, as each page is responsible for laying out the view components. This simple solution lacks foresight. With so much HTML and JSP code duplication, we minimize the number of pages but at a heavy maintenance cost. There is strong coupling between the different view components, which, as I e<a title="" href="http://www.xgdown.com/article/44/ArticleList44_1.htm" target="_blank">XP</a>lained earlier, is undesirable. 
</p><p><strong>Solution 2: JSP include </strong><br />Consider the following JSP for <code>a.jsp</code>: <code><p>&lt;html&gt;<br />&lt;body&gt;<br /><br />&lt;%-- include header --%&gt;<br />&lt;jsp:include page="/header.jsp" /&gt;<br /><br />a's body...<br />&lt;p&gt;<br /><br />&lt;%-- include footer --%&gt;<br />&lt;jsp:include page="/footer.jsp" /&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p></code></p><p>Consider the following JSP for <code>b.jsp</code>: <code><p>&lt;html&gt;<br />&lt;body&gt;<br /><br />&lt;%-- include header --%&gt;<br />&lt;jsp:include page="/header.jsp" /&gt;<br /><br />b's body...<br />&lt;p&gt;<br /><br />&lt;%-- include footer --%&gt;<br />&lt;jsp:include page="/footer.jsp" /&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p></code></p><p>Note that common view components, like header and footer, are split up using the JSP <code>include</code> mechanism. 
</p><p>Consider this <code>header.jsp</code>: <code><p>Header<br />&lt;p&gt;<br /></p></code></p><p>Consider this <code>footer.jsp</code>: <code><p>Footer <br />&lt;p&gt;<br /></p></code></p><p>Solution 2 nicely addresses some of Solution 1's major shortcomings. You only need to change common view components once. Hence, this solution greatly eliminates HTML and JSP code repetition, significantly improving application maintainability. It increases the page number a bit, but drastically reduces the tight coupling between common view components and other pages. On the complexity scale, this solution is simple and readily implemented on many real-world applications. However, it has one major drawback: if you change how and where you organize the view components (i.e., by changing the component layout), then you would need to update every page -- resulting in an e<a title="" href="http://www.xgdown.com/article/44/ArticleList44_1.htm" target="_blank">XP</a>ensive and prohibitive change. Solution 2 achieves view component reuse, but does not achieve the reuse of layout and templating logic. 
</p><p><strong>Solution 3: Tiles insert </strong><br />Consider this JSP for <code>a.jsp</code>: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;html&gt;<br />&lt;body&gt;<br /><br />&lt;%-- include header --%&gt;<br />&lt;tiles:insert page="/header.jsp" flush="true"/&gt;<br /><br />a's body...<br />&lt;p&gt;<br /><br />&lt;%-- include footer --%&gt;<br />&lt;tiles:insert page="/footer.jsp" flush="true"/&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p></code></p><p>Consider this JSP for <code>b.jsp</code>: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;html&gt;<br />&lt;body&gt;<br /><br />&lt;%-- include header --%&gt;<br />&lt;tiles:insert page="/header.jsp" flush="true"/&gt;<br /><br />b's body...<br />&lt;p&gt;<br /><br />&lt;%-- include footer --%&gt;<br />&lt;tiles:insert page="/footer.jsp" flush="true"/&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p></code></p><p>Instead of using the JSP <code>include</code> mechanism, Solution 3 uses the Tiles <code>insert</code> mechanism. Using the Tiles <code>insert</code> tag, you include the view components in the appropriate positions. In all other <a title="" href="http://www.xgdown.com/article/4/ArticleList4_1.htm" target="_blank">ASP</a>ects, the solution mirrors the JSP <code>include</code> solution (Solution 2) exactly, with the same advantages and disadvantages. 
</p><p><strong>Solution 4: Splitting bodies </strong><br />Consider this <code>a.jsp</code>: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;html&gt;<br />&lt;body&gt;<br /><br />&lt;%-- include header --%&gt;<br />&lt;tiles:insert page="/header.jsp" flush="true"/&gt;<br /><br />&lt;%-- include body --%&gt;<br />&lt;tiles:insert page="aBody.jsp" flush="true"/&gt;<br /><br />&lt;%-- include footer --%&gt;<br />&lt;tiles:insert page="/footer.jsp" flush="true"/&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /><br /></p></code></p><p>Consider this <code>b.jsp</code>: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;html&gt;<br />&lt;body&gt;<br /><br />&lt;%-- include header --%&gt;<br />&lt;tiles:insert page="/header.jsp" flush="true"/&gt;<br /><br />&lt;%-- include body --%&gt;<br />&lt;tiles:insert page="bBody.jsp" flush="true"/&gt;<br /><br />&lt;%-- include footer --%&gt;<br />&lt;tiles:insert page="/footer.jsp" flush="true"/&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p></code></p><p>Solution 4 differs slightly from the Tiles <code>insert</code> solution. Solution 4 separates the core bodies into their individual pages, like <code>aBody.jsp</code> and <code>bBody.jsp</code>. 
</p><p>Consider the following JSP for <code>aBody.jsp</code>: <code><p>a's body...<br />&lt;p&gt;<br /></p></code></p><p>Consider the following JSP for <code>bBody.jsp</code>: <code><p>b's body...<br />&lt;p&gt;<br /></p></code></p><p>Solution 4's advantage: it limits body changes to the respective pages. Also, it lets you reuse the bodies in other places, eliminating the need for repetition and duplication. Thus, the solution further diminishes the coupling between common view components and other application components. Creating and managing each body component introduces an additional complexity level. As with other solutions, each page still does its own layout. Hence, there is no overarching layout policy or scheme. 
</p><p><strong>Solution 5: Templating tiles </strong><br />Using Tiles's templating feature, you can define the following layout (from the <code>layout.jsp</code> file shown below) as a template. Since this is a layout, you insert placeholders instead of the actual view components using the Tiles <code>insert</code> tag. Thus, for all components, this page defines one reusable layout: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;html&gt;<br />&lt;body&gt;<br /><br />    &lt;%-- include header --%&gt;<br />    &lt;tiles:insert attribute="header"/&gt;<br />    <br />    &lt;%-- include body --%&gt;<br />    &lt;tiles:insert attribute="body"/&gt;<br />    <br />    &lt;%-- include footer --%&gt;<br />    &lt;tiles:insert attribute="footer"/&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p></code></p><p>Other content pages, like <code>a.jsp</code> and <code>b.jsp</code>, use the above layout for arranging components. In the actual page, you insert the layout using the Tiles <code>insert</code> tag. Using the Tiles <code>put</code> tag, you can specify the actual view components for all placeholders specified in the layout. 
</p><p>Consider this <code>a.jsp</code>: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;tiles:insert page="/layout.jsp" flush="true"&gt;<br />    &lt;tiles:put name="header" value="/header.jsp"/&gt;<br />    &lt;tiles:put name="body" value="/aBody.jsp"/&gt;<br />    &lt;tiles:put name="footer" value="/footer.jsp"/&gt;    <br />&lt;/tiles:insert&gt;<br /></p></code></p><p>Consider this <code>b.jsp</code>: <code><p>&lt;%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %&gt;<br /><br />&lt;tiles:insert page="/layout.jsp" flush="true"&gt;<br />    &lt;tiles:put name="header" value="/header.jsp"/&gt;<br />    &lt;tiles:put name="body" value="/bBody.jsp"/&gt;<br />    &lt;tiles:put name="footer" value="/footer.jsp"/&gt;    <br />&lt;/tiles:insert&gt;<br /></p></code></p><p>Solution 5's most significant advantage is that it encapsulates the layout scheme or mechanism, drastically reducing the coupling between common view components and other content bodies. However, it increases complexity by introducing another layout page. Understanding and implementing templating can also be difficult at first. 
</p><p><strong>Solution 6: Struts and Tiles </strong><br />The above layout page, <code>layout.jsp</code>, contains the HTML and JSP code for organizing the components. The content pages, <code>a.jsp</code> and <code>b.jsp</code>, do not contain any HTML code; they just contain the Tiles tags to insert the necessary components. Wouldn't it be nice to specify all the content pages in one <a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> configuration file? 
</p><p>Let's name that file <code>tileDefinitions.<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a></code> and specify its pages as: 
</p><p><code><p>&lt;?<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> version="1.0" encoding="ISO-8859-1"?&gt;<br />&lt;component-definitions&gt;<br />    &lt;definition name="aDef" path="/layout.jsp"&gt;<br />        &lt;put name="header" value="/header.jsp"/&gt;<br />        &lt;put name="footer" value="/footer.jsp"/&gt;<br />        &lt;put name="body" value="/aBody.jsp"/&gt;<br />    &lt;/definition&gt;<br />    &lt;definition name="bDef" path="/layout.jsp"&gt;<br />        &lt;put name="header" value="/header.jsp"/&gt;<br />        &lt;put name="footer" value="/footer.jsp"/&gt;<br />        &lt;put name="body" value="/bBody.jsp"/&gt;<br />    &lt;/definition&gt;<br />    &lt;definition name="cDef" path="/layout.jsp"&gt;<br />        &lt;put name="header" value="/header.jsp"/&gt;<br />        &lt;put name="footer" value="/footer.jsp"/&gt;<br />        &lt;put name="body" value="/cBody.jsp"/&gt;<br />    &lt;/definition&gt;<br />&lt;/component-definitions&gt;<br /></p></code></p><p>Solution 6 eliminates all the content pages, like <code>a.jsp</code> and <code>b.jsp</code>, by putting their definitions in the <a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> file. Since a resource like <code>a.jsp</code> no longer exists, how can we request it? More importantly, how can we request the definitions in the <code>tileDefinitions.<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a></code> file? 
</p><p>The powerful and synergistic integration of Struts and Tiles comes to the rescue. Besides the regular Struts configuration parameters, we specify the configuration file's location as another parameter in the <code>web.<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a></code> file, as shown below. Specifying the <code>definitions-config</code> parameter enables Struts to find and know about the Tiles definitions: <code><p>  &lt;!-- Standard Action Servlet Configuration (with debugging) --&gt;<br />  &lt;servlet&gt;<br />    &lt;servlet-name&gt;action&lt;/servlet-name&gt;<br />&lt;!--<br />    &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;<br />--&gt;<br />    &lt;servlet-class&gt;org.apache.struts.tiles.ActionComponentServlet&lt;/servlet-class&gt;<br />    &lt;init-param&gt;<br />        &lt;param-name&gt;definitions-config&lt;/param-name&gt;<br />        &lt;param-value&gt;/WEB-INF/tileDefinitions.<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a>&lt;/param-value&gt;<br />    &lt;/init-param&gt;<br />    ...<br />  &lt;/servlet&gt;<br /></p></code></p><p>Now, we define a Struts action, which returns a definition specified in the configuration file upon success. The Struts action <code>DoFirst</code> is a nonoperational action, as shown below: <code><p>package com.malani.struts.action;<br /><br />import org.apache.struts.action.*;<br />import <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>x.servlet.http.*;<br /><br />public class DoFirst extends Action {<br /><br />    public ActionForward perform(<br />        ActionMapping aMapping,<br />        ActionForm aForm,<br />        HttpServletRequest aRequest,<br />        HttpServletResponse aResponse<br />    ) {<br />        return aMapping.findForward("success");<br />    }<br /><br />}<br /></p></code></p><p>You cannot invoke a definition directly from the browser, but you can invoke one from Struts as if it is an actual resource. Define the Struts actions in the <code>struts-config.<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a></code> file as shown below: <code><p>    &lt;action path="/a"<br />            type="com.malani.struts.action.DoFirst"<br />    &gt;<br />        &lt;forward name="success" path="aDef"/&gt;<br />    &lt;/action&gt;<br /><br />    &lt;action path="/b"<br />            type="com.malani.struts.action.DoFirst"<br />    &gt;<br />        &lt;forward name="success" path="bDef"/&gt;<br />    &lt;/action&gt;<br /><br />    &lt;action path="/c"<br />            type="com.malani.struts.action.DoFirst"<br />    &gt;<br />        &lt;forward name="success" path="cDef"/&gt;<br />    &lt;/action&gt;<br /></p></code></p><p>Now, invoke the Struts action by requesting <code>a.do</code> and <code>b.do</code> actions respectively to return the desired resource. 
</p><p>Solution 6's main advantage is that it consolidates all definitions in an <a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> configuration file. Eliminating the content pages drastically reduces the total page number. By introducing Struts, we turn up the complexity another notch. 
</p><p><strong>Solution 7: Tiles inheritance </strong><br />In the definitions configuration file, observe that each page's definition looks similar. Each definition has three components, two of which are fixed as header and footer. A powerful Tiles feature enables inheritance between definitions. Hence, you can define a base definition and let the original definitions inherit from that definition. The original definitions must only supply their unique part. The following shows the <a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> configuration file with inheritance between definitions: <code><p>&lt;?<a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a> version="1.0" encoding="ISO-8859-1"?&gt;<br />&lt;component-definitions&gt;<br />    &lt;definition name="baseDef" path="/layout.jsp"&gt;<br />        &lt;put name="header" value="/header.jsp"/&gt;<br />        &lt;put name="footer" value="/footer.jsp"/&gt;<br />        &lt;put name="body" value=""/&gt;<br />    &lt;/definition&gt;<br />    &lt;definition name="aDef" extends="baseDef"&gt;<br />        &lt;put name="body" value="/aBody.jsp"/&gt;<br />    &lt;/definition&gt;<br />    &lt;definition name="bDef" extends="baseDef"&gt;<br />        &lt;put name="body" value="/bBody.jsp"/&gt;<br />    &lt;/definition&gt;<br />    &lt;definition name="cDef" extends="baseDef"&gt;<br />        &lt;put name="body" value="/cBody.jsp"/&gt;<br />    &lt;/definition&gt;<br />&lt;/component-definitions&gt;<br /></p></code></p><p>Elimination of duplicate and redundant information in the configuration file is an advantage of this solution. Overall, the advantages and disadvantages of this solution are identical to the Struts and Tiles solution. 
</p><p><font size="+1"><strong>Solution summary </strong></font><br />The following table summarizes the different solutions with respect to the evaluation criteria. I encourage you to add other creative solutions as well as other important evaluation criteria, such as extensibility, maintainability, and performance. 
</p><p><strong>Evaluate various solutions per specified criteria</strong></p><table cellspacing="1" cellpadding="0" bgcolor="#000000" border="0"><tbody><tr><td><table cellspacing="1" cellpadding="5" border="0"><tbody><tr bgcolor="#990033"><td><font color="#ffffff">Solution</font></td><td><font color="#ffffff">Page number</font></td><td><font color="#ffffff">Code repetition</font></td><td><font color="#ffffff">Layout control</font></td><td><font color="#ffffff">Coupling</font></td><td><font color="#ffffff">Complexity</font></td></tr><tr bgcolor="#cccccc"><td>1: Basic</td><td>*</td><td>***</td><td>*</td><td>***</td><td>*</td></tr><tr bgcolor="#ffffff"><td>2: JSP include</td><td>**</td><td>**</td><td>*</td><td>**</td><td>*</td></tr><tr bgcolor="#cccccc"><td>3: Tiles insert</td><td>**</td><td>**</td><td>*</td><td>**</td><td>*</td></tr><tr bgcolor="#ffffff"><td>4: Splitting bodies</td><td>***</td><td>**</td><td>**</td><td>**</td><td>**</td></tr><tr bgcolor="#cccccc"><td>5: Templating tiles</td><td>***</td><td>*</td><td>***</td><td>*</td><td>**</td></tr><tr bgcolor="#ffffff"><td>6: Struts and Tiles</td><td>**</td><td>*</td><td>***</td><td>*</td><td>***</td></tr><tr bgcolor="#cccccc"><td>7: Tiles inheritance</td><td>**</td><td>*</td><td>***</td><td>*</td><td>***</td></tr><tr bgcolor="#ffffff"><td colspan="6"><strong>Scale:</strong> High: ***   Medium: **   Low: *</td></tr></tbody></table></td></tr></tbody></table><p>The table shows that each solution's complexity level gradually increases. It also shows that as you increase complexity, you reduce code repetition, increase layout-control flexibility, and diminish coupling between unrelated view components. The page number initially increases as various view components split, but as you define more pages in a definitions configuration file, consolidation will occur. </p><p><font size="+1"><strong>Divine design </strong></font><br />In this article, I evaluated various solutions for organizing view components in HTML and JSPs. I also e<a title="" href="http://www.xgdown.com/article/44/ArticleList44_1.htm" target="_blank">XP</a>lored the synergy between the Struts and Tiles frameworks. These strategies and solutions will help you make informed design and architectural decisions regarding your Web applications. 
</p><p><em>I would sincerely like to thank Max Cooper, Stephen Ditlinger, Dru Jensen, Phillip Lindsay, Roshni Malani, Danny Trieu, and Clare Zhang for reviewing this article.</em><img title="" height="12" src="http://www.devworld.com/microsites/%3Ca%20href=" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="" />Javaworld/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/icons/jw-dingbat.gif" width=22&gt; 
</p><p><br /></p><font size="-1"><!-- REPLACE PAGEURLS --></font><!-- REPLACE TALKBACK --><p><img title="" height="15" alt="Printer-friendly version" src="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="" />Javaworld.com/images/jw-print-icon.gif" width=16 align=absMiddle vspace=4 border=0&gt; <a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/jw-0104-tilestrut_p.html"&gt;<font color="#002c99">Printer-friendly version</font><img title="" height="15" alt="Send this article to a friend" src="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="" />Javaworld.com/images/jw-email-icon.gif" width=20 border=0&gt; <a title="" href="http://www.xgdown.com/article/239/%3Ca%20href=" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>script:mail2Friend()"&gt;<font color="#002c99">Mail this to a friend</font></p><p><strong>About the author</strong><br /><a title="" href="http://www.xgdown.com/article/239/%3Ca%20href=" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>script:openBrWindow()"&gt;<font color="#002c99">Prakash Malani</font> has extensive e<a title="" href="http://www.xgdown.com/article/44/ArticleList44_1.htm" target="_blank">XP</a>erience in designing and developing object-oriented software using <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a> and <a title="" href="http://www.xgdown.com/article/236/ArticleList236_1.htm" target="_blank">C++</a>. He has been developing software in many application domains, such as e-commerce, retail, medicine, communications, and interactive television. He practices leading technologies, such as object-oriented analysis &amp; design (OOAD), the Unified Modeling Language (UML), <a title="" href="http://www.xgdown.com/article/203/ArticleList203_1.htm" target="_blank">XML</a>, Enterprise <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>Beans (EJBs), <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>Server Pages (JSPs), and more. He teaches <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a> and related technologies at various institutions, including University of California, Irvine and California State Polytechnic University, Pomona. <br /></p><p></p><ul><a name="resources"></a><strong>Resources</strong><br /><li>Download the complete source code for Solution 1. Basic JSP: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/1_basic.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/1_basic.zip </font><br /></li><li>Download the complete source code for Solution 2. JSP include: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/2_JSPinclude.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/2_JSPinclude.zip </font><br /></li><li>Download the complete source code for Solution 3. Tiles insert: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/3_tilesInsert.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/3_tilesInsert.zip </font><br /></li><li>Download the complete source code for Solution 4. Splitting bodies: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/4_bodies.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/4_bodies.zip </font><br /></li><li>Download the complete source code for Solution 5. Templating tiles: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/5_templatingTiles.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/5_templatingTiles.zip </font><br /></li><li>Download the complete source code for Solution 6. Struts and Tiles: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/6_struts.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/6_struts.zip </font><br /></li><li>Download the complete source code for Solution 7. Tiles inheritance: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/7_inheritance.zip"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-01-2002/tilestrut/7_inheritance.zip </font><br /></li><li>The Tiles framework: <br /><a href="http://www.lifl.fr/~dumoulin/tiles/"><font color="#002c99">http://www.lifl.fr/~dumoulin/tiles/ </font></a><br /></li><li>See also "Strut Your Stuff with JSP Tags," Thor Kristmundsson (<em><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>World,</em> December <a title="" href="http://www.xgdown.com/article/42/ArticleList42_1.htm" target="_blank">2000</a>): <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-12-<a title="" href="http://www.xgdown.com/article/42/ArticleList42_1.htm" target="_blank">2000</a>/jw-1201-struts.html"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world/jw-12-<a title="" href="http://www.xgdown.com/article/42/ArticleList42_1.htm" target="_blank">2000</a>/jw-1201-struts.html </font><br /></li><li><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a> Servlet and <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>Server Pages specification: <br /><a title="" href="http://www.jcp.org/about%3Ca%20href=" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>/communityprocess/final/jsr053/"&gt;<font color="#002c99">http://www.jcp.org/about<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>/communityprocess/final/jsr053/ </font><br /></li><li>Browse <em><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>World'</em>s <strong>Servlets</strong> Index: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/channel_content/jw-servlets-index.shtml"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/channel_content/jw-servlets-index.shtml </font><br /></li><li>Browse <em><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>World'</em>s <strong><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>Server Pages</strong> Index: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/channel_content/jw-jsp-index.shtml"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/channel_content/jw-jsp-index.shtml </font><br /></li><li>Browse <em><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>World'</em>s <strong>User Interface Design</strong> Index: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/channel_content/jw-ui-index.shtml"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/channel_content/jw-ui-index.shtml </font><br /></li><li>Subscribe to <em><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>World'</em>s free weekly email newsletters: <br /><a title="" href="http://www.%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 239="" articlelist239_1.htm?="">Java</a>world.com/subscribe"&gt;<font color="#002c99">http://www.<a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>world.com/subscribe </font><br /></li><li>Speak out in <em><a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a>World'</em>s <a title="" href="http://www.xgdown.com/article/239/ArticleList239_1.htm" target="_blank">Java</a> Forum: <br /><a href="http://forums.devworld.com/webx?13@@.ee6b802"><font color="#002c99">http://forums.devworld.com/webx?13@@.ee6b802 </font></a><br /></li><li>You'll find a wealth of IT-related articles from our sister publications at <a title="" href="http://www.idg%3ca%20href=/" target="_blank" http:="" www.xgdown.com="" article="" 140="" articlelist140_1.htm?="">.net</a>/jump?id=1100"&gt;<font color="#002c99">IDG<a title="" href="http://www.xgdown.com/article/140/ArticleList140_1.htm" target="_blank">.net</a></font></li></ul><img src ="http://www.blogjava.net/liaojiyong/aggbug/106309.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2007-03-26 09:38 <a href="http://www.blogjava.net/liaojiyong/archive/2007/03/26/106309.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts+Hibernate中解决汉字编码问题（转）</title><link>http://www.blogjava.net/liaojiyong/archive/2007/03/23/105721.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Fri, 23 Mar 2007 01:42:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2007/03/23/105721.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/105721.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2007/03/23/105721.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/105721.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/105721.html</trackback:ping><description><![CDATA[1. 首先所有的文字编码均采用<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">UTF-8格式，至于为什么要采用<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">UTF-8.　　<br />&lt;%@ page language="java" contentType="text/html; charset=utf-8" %&gt;</span></span><p><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">2. struts框架提供了资源信息文件，它包含了jsp页面内容的一些文字说明，以及另一些供代码中使用的信息输出等（说白了，就是些文字描述定义，可以当成变量看待）。<br /><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">ApplicationResources.properties（默认的是英文<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">ApplicationResources.properties</span>一份，命名为：<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">ApplicationResources_zh_CN.properties 简体中文<br />ApplicationResources_zh_TW.properties 繁体中文<br /></span>　<br />然后,执行JDK自带的命令如下：<br /></span></span></span><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">native2ascii -encoding gb2312 ApplicationResources_demo.properties ApplicationResources_zh_CN.properties<br /></span></span></span></span><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">3. struts中，对于中文参数的传递的文字编码处理，一般加个<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">过滤器类就可以了的。<br />java源代码如下：<br /></span></span></span></span></p><p><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">import java.io.IOException;<br />import javax.servlet.Filter;<br />import javax.servlet.FilterChain;<br />import javax.servlet.FilterConfig;<br />import javax.servlet.ServletException;<br />import javax.servlet.ServletRequest;<br />import javax.servlet.ServletResponse;<br />import javax.servlet.UnavailableException;<br /></span></span></span></span></p><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-bidi-font-size: 12.0pt; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><p><br />public class SetCharacterEncodingFilter implements Filter<br />{ <br /> protected String encoding = null; <br /> protected FilterConfig filterConfig = null; <br /> protected boolean ignore = true; <br /> <br /> public void destroy()<br /> { <br />  this.encoding = null; <br />  this.filterConfig = null; <br /> } </p><p> public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) <br />   throws IOException, ServletException <br /> { <br />  if (ignore || (request.getCharacterEncoding() == null))<br />  { <br />   String encoding = selectEncoding(request); <br />   if (encoding != null) <br />    request.setCharacterEncoding(encoding); <br />  } <br />  chain.doFilter(request, response); <br /> } </p><p> public void init(FilterConfig filterConfig) throws ServletException<br /> { <br />  this.filterConfig = filterConfig; <br />  this.encoding = filterConfig.getInitParameter("encoding"); <br />  String value = filterConfig.getInitParameter("ignore"); <br />  if (value == null) <br />   this.ignore = true; <br />  else if (value.equalsIgnoreCase("true")) <br />   this.ignore = true; <br />  else if (value.equalsIgnoreCase("yes")) <br />   this.ignore = true; <br />  else <br />   this.ignore = false; <br /> } </p><p> protected String selectEncoding(ServletRequest request) <br /> { <br />  return (this.encoding); <br /> } <br />}<br />4.  配置web.xml文件<br /><br />  在&lt;web-app&gt;下加下面的代码</p><p>&lt;filter&gt; <br /> &lt;filter-name&gt;Set Character Encoding&lt;/filter-name&gt; <br /> &lt;filter-class&gt;com.zxjsoft.util.SetCharacterEncodingFilter&lt;/filter-class&gt; <br /> &lt;init-param&gt; <br />  &lt;param-name&gt;encoding&lt;/param-name&gt; <br />  &lt;param-value&gt;utf-8&lt;/param-value&gt; <br /> &lt;/init-param&gt; <br /> &lt;init-param&gt; <br />  &lt;param-name&gt;ignore&lt;/param-name&gt; <br />  &lt;param-value&gt;true&lt;/param-value&gt; <br /> &lt;/init-param&gt; <br />&lt;/filter&gt;</p><p>&lt;filter-mapping&gt; <br /> &lt;filter-name&gt;Set Character Encoding&lt;/filter-name&gt; <br /> &lt;servlet-name&gt;action&lt;/servlet-name&gt; <br />&lt;/filter-mapping&gt;<br /><br />5.对于hibernate如说 还得配置hibernate.cfg.xml文件<br /> 在文件里加入<br /> &lt;property name="hibernate.connection.useUnicode"&gt;true&lt;/property&gt;<br /> &lt;property name="hibernate.connection.characterEncoding"&gt;UTF-8(或者gb2312)&lt;/property&gt;</p></span></span></span></span><img src ="http://www.blogjava.net/liaojiyong/aggbug/105721.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2007-03-23 09:42 <a href="http://www.blogjava.net/liaojiyong/archive/2007/03/23/105721.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts多国语言国际化处理(现以中文英文切换为例) （转）</title><link>http://www.blogjava.net/liaojiyong/archive/2007/03/23/105717.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Fri, 23 Mar 2007 01:39:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2007/03/23/105717.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/105717.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2007/03/23/105717.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/105717.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/105717.html</trackback:ping><description><![CDATA[
		<p>1.引言<br />  因为最近有个英国的项目要求中英文切换，又由于我们开发是用struts+hibernate的，所以我们就把原先做两个版本的构思抛掉，就用struts的国际化处理方案。<br />2.资料<br />  首先，我们要准备两份配置文件中文和英文的<br />  中文:ApplicationResources_zh_CN.properties<br />  英文:ApplicationResources_en.properties  (千万不要用默认的ApplicationResources.properties myeclipse自动生成，可能会不成功，我起先就是因为这个怎么都不行的，呵呵！)<br />3.准备开始<br />1) ApplicationResources_zh_CN.properties的内容<br />#zh_CN<br />username=纯冰<br />2)ApplicationResources_en.properties的内容<br />#en<br />username=chunkyo<br />3)一个action<br />/*<br /> * Generated by MyEclipse Struts<br /> * Template path: templates/java/JavaClass.vtl<br /> */<br />package com.lan.struts.action;</p>
		<p>import javax.servlet.http.HttpServletRequest;<br />import javax.servlet.http.HttpServletResponse;<br />import org.apache.struts.action.Action;<br />import org.apache.struts.action.ActionForm;<br />import org.apache.struts.action.ActionForward;<br />import org.apache.struts.action.ActionMapping;</p>
		<p>import org.apache.struts.Globals;<br />import java.util.Locale;</p>
		<p>/** <br /> * MyEclipse Struts<br /> * Creation date: 02-07-2007<br /> * <br /> * XDoclet definition:<br /> * @struts.action validate="true"<br /> */<br />public class ChangeLanguageAction extends Action {<br /> /*<br />  * Generated Methods<br />  */</p>
		<p> /** <br />  * Method execute<br />  * @param mapping<br />  * @param form<br />  * @param request<br />  * @param response<br />  * @return ActionForward<br />  */<br /> public ActionForward execute(ActionMapping mapping, ActionForm form,<br />   HttpServletRequest request, HttpServletResponse response) {<br />  // TODO Auto-generated method stub<br />  String lan=request.getParameter("lan");<br />  if(lan.equals("1"))<br />  {<br />   request.getSession().setAttribute(Globals.LOCALE_KEY,Locale.CHINA);<br />  }<br />  else if(lan.equals("0"))<br />  {<br />   request.getSession().setAttribute(Globals.LOCALE_KEY,Locale.ENGLISH);<br />  }<br />  else<br />  {<br />   request.getSession().setAttribute(Globals.LOCALE_KEY,Locale.CHINA);<br />  }<br />  return mapping.findForward("index");<br /> }<br />}<br /><br />4)一个页面<br />&lt;%@ page language="java" pageEncoding="utf-8"%&gt;<br />&lt;%@ taglib uri="<a href="http://jakarta.apache.org/struts/tags-bean"><font color="#000000">http://jakarta.apache.org/struts/tags-bean</font></a>" prefix="bean" %&gt;<br />&lt;%@ taglib uri="<a href="http://jakarta.apache.org/struts/tags-html"><font color="#000000">http://jakarta.apache.org/struts/tags-html</font></a>" prefix="html" %&gt;<br />&lt;%@ taglib uri="<a href="http://jakarta.apache.org/struts/tags-logic"><font color="#000000">http://jakarta.apache.org/struts/tags-logic</font></a>" prefix="logic" %&gt;</p>
		<p>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;<br />&lt;html:html locale="true"&gt;<br />  &lt;head&gt;<br />    &lt;html:base /&gt;<br />    <br />    &lt;title&gt;&lt;bean:message key="username"/&gt;&lt;/title&gt;</p>
		<p> &lt;meta http-equiv="pragma" content="no-cache"&gt;<br /> &lt;meta http-equiv="cache-control" content="no-cache"&gt;<br /> &lt;meta http-equiv="expires" content="0"&gt;    <br /> &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;<br /> &lt;meta http-equiv="description" content="This is my page"&gt;<br /> &lt;!--<br /> &lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;<br /> --&gt;</p>
		<p>  &lt;/head&gt;<br />  <br />  &lt;body&gt;<br />    &lt;html:link page="/changeLanguage.do?lan=0"&gt;English&lt;/html:link&gt;<br />    &lt;html:link page="/changeLanguage.do?lan=1"&gt;Chinese&lt;/html:link&gt;<br />    &lt;bean:message key="username"/&gt;<br />  &lt;/body&gt;<br />&lt;/html:html&gt;<br />4)配置文件(struts-config.xml)<br />&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "<a href="http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"><font color="#000000">http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd</font></a>"&gt;</p>
		<p>&lt;struts-config&gt;<br />  &lt;data-sources /&gt;<br />  &lt;form-beans /&gt;<br />  &lt;global-exceptions /&gt;<br />  &lt;global-forwards &gt;<br />    &lt;forward name="index" path="/index.jsp" /&gt;</p>
		<p>  &lt;/global-forwards&gt;</p>
		<p>  &lt;action-mappings &gt;<br />    &lt;action path="/changeLanguage" type="com.lan.struts.action.ChangeLanguageAction" /&gt;</p>
		<p>  &lt;/action-mappings&gt;&lt;message-resources parameter="com.lan.struts.ApplicationResources" /&gt;<br />&lt;/struts-config&gt;</p>
		<p>5)结果<br /> 1。默认<br /><a href="http://localhost:8080/lan/changeLanguage.do?lan=0"><font color="#000000">http://localhost:8080/lan/</font></a><br /><a href="http://localhost:8080/lan/changeLanguage.do?lan=0"><font color="#000000">English</font></a><a href="http://localhost:8080/lan/changeLanguage.do?lan=1"><font color="#000000">Chinese</font></a> 纯冰<br />2。英文<br /><a href="http://localhost:8080/lan/changeLanguage.do?lan=0"><font color="#000000">http://localhost:8080/lan/changeLanguage.do?lan=0</font></a><br /><a href="http://localhost:8080/lan/changeLanguage.do?lan=0"><font color="#000000">English</font></a><a href="http://localhost:8080/lan/changeLanguage.do?lan=1"><font color="#000000">Chinese</font></a> chunkyo <br />3。中文<br /><a href="http://localhost:8080/lan/changeLanguage.do?lan=1"><font color="#000000">http://localhost:8080/lan/changeLanguage.do?lan=1</font></a><br /><a href="http://localhost:8080/lan/changeLanguage.do?lan=0"><font color="#000000">English</font></a><a href="http://localhost:8080/lan/changeLanguage.do?lan=1"><font color="#000000">Chinese</font></a> 纯冰 <br />6)结论<br />用struts做国际化处理 多国语言处理很方便 呵呵！</p>
<img src ="http://www.blogjava.net/liaojiyong/aggbug/105717.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2007-03-23 09:39 <a href="http://www.blogjava.net/liaojiyong/archive/2007/03/23/105717.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts2与Struts1的对比 </title><link>http://www.blogjava.net/liaojiyong/archive/2007/01/12/93428.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Fri, 12 Jan 2007 06:30:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2007/01/12/93428.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/93428.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2007/01/12/93428.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/93428.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/93428.html</trackback:ping><description><![CDATA[
		<p>Action 类: <br />• Struts1要求Action类继承一个抽象基类。Struts1的一个普遍问题是使用抽象类编程而不是接口。 <br />• Struts 2 Action类可以实现一个Action接口，也可实现其他接口，使可选和定制的服务成为可能。Struts2提供一个ActionSupport基类去实现 常用的接口。Action接口不是必须的，任何有execute标识的POJO对象都可以用作Struts2的Action对象。 <br />线程模式: <br />• Struts1 Action是单例模式并且必须是线程安全的，因为仅有Action的一个实例来处理所有的请求。单例策略限制了Struts1 Action能作的事，并且要在开发时特别小心。Action资源必须是线程安全的或同步的。 <br />• Struts2 Action对象为每一个请求产生一个实例，因此没有线程安全问题。（实际上，servlet容器给每个请求产生许多可丢弃的对象，并且不会导致性能和垃圾回收问题） </p>
		<p>Servlet 依赖: <br />• Struts1 Action 依赖于Servlet API ,因为当一个Action被调用时HttpServletRequest 和 HttpServletResponse 被传递给execute方法。 <br />• Struts 2 Action不依赖于容器，允许Action脱离容器单独被测试。如果需要，Struts2 Action仍然可以访问初始的request和response。但是，其他的元素减少或者消除了直接访问HttpServetRequest 和 HttpServletResponse的必要性。 </p>
		<p>可测性: <br />• 测试Struts1 Action的一个主要问题是execute方法暴露了servlet API（这使得测试要依赖于容器）。一个第三方扩展－－Struts TestCase－－提供了一套Struts1的模拟对象（来进行测试）。 <br />• Struts 2 Action可以通过初始化、设置属性、调用方法来测试，“依赖注入”支持也使测试更容易。 </p>
		<p>捕获输入: <br />• Struts1 使用ActionForm对象捕获输入。所有的ActionForm必须继承一个基类。因为其他JavaBean不能用作ActionForm，开发者经常创建多余的类捕获输入。动态Bean（DynaBeans）可以作为创建传统ActionForm的选择，但是，开发者可能是在重新描述(创建)已经存在的JavaBean（仍然会导致有冗余的javabean）。 <br />• Struts 2直接使用Action属性作为输入属性，消除了对第二个输入对象的需求。输入属性可能是有自己(子)属性的rich对象类型。Action属性能够通过web页面上的taglibs访问。Struts2也支持ActionForm模式。rich对象类型，包括业务对象，能够用作输入/输出对象。这种ModelDriven 特性简化了taglib对POJO输入对象的引用。 </p>
		<p>表达式语言： <br />• Struts1 整合了JSTL，因此使用JSTL EL。这种EL有基本对象图遍历，但是对集合和索引属性的支持很弱。 <br />• Struts2可以使用JSTL，但是也支持一个更强大和灵活的表达式语言－－"Object Graph Notation Language" (OGNL). </p>
		<p>绑定值到页面（view）: <br />• Struts 1使用标准JSP机制把对象绑定到页面中来访问。 <br />• Struts 2 使用 "ValueStack"技术，使taglib能够访问值而不需要把你的页面（view）和对象绑定起来。ValueStack策略允许通过一系列名称相同但类型不同的属性重用页面（view）。 <br />　 <br />类型转换： <br />• Struts 1 ActionForm 属性通常都是String类型。Struts1使用Commons-Beanutils进行类型转换。每个类一个转换器，对每一个实例来说是不可配置的。 <br />• Struts2 使用OGNL进行类型转换。提供基本和常用对象的转换器。 </p>
		<p>校验： <br />• Struts 1支持在ActionForm的validate方法中手动校验，或者通过Commons Validator的扩展来校验。同一个类可以有不同的校验内容，但不能校验子对象。 <br />• Struts2支持通过validate方法和XWork校验框架来进行校验。XWork校验框架使用为属性类类型定义的校验和内容校验，来支持chain校验子属性 </p>
		<p>Action执行的控制： <br />• Struts1支持每一个模块有单独的Request Processors（生命周期），但是模块中的所有Action必须共享相同的生命周期。 <br />• Struts2支持通过拦截器堆栈（Interceptor Stacks）为每一个Action创建不同的生命周期。堆栈能够根据需要和不同的Action一起使用。</p>
<img src ="http://www.blogjava.net/liaojiyong/aggbug/93428.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2007-01-12 14:30 <a href="http://www.blogjava.net/liaojiyong/archive/2007/01/12/93428.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>完全解决java开发中的中文问题（侧重struts（转）</title><link>http://www.blogjava.net/liaojiyong/archive/2006/09/01/67079.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Fri, 01 Sep 2006 05:42:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2006/09/01/67079.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/67079.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2006/09/01/67079.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/67079.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/67079.html</trackback:ping><description><![CDATA[
		<div class="postTitle"> </div>
		<p>       在做java开发的过程中一开始就碰到中文问题，刚接触到java时用的编译器是JCreate,这是个非常好用简单的java编译器，<br />但他就在对中文的支持上有很大问题，当时我就在想中国这么大的国家为什么在世界上总是比不过那些小国家，最严重的是有日文开发文档<br />就是没有中文的，所以我们在开发java的时候总是会碰到中文问题。下面我就来说一下我在开发中是如何来处理中文的。<br />      首先讲中文的字符的编码，刚开始中文的编码是GB2312后来发现他的常用字根本不能适应现在的需求，所以就在他的基础上增加了很多<br />生僻字，不常用字得到了新的编码GBK，我们一般来说都用GBK来实现我们的开发，而如果说到国际化就不得不提Unicode （统一码）顾名思<br />义是一个将世界上各种文字统一在一起的东东。由美国各大电脑厂商组成的Unicode策进会来推动。目的，推广一个世界通用的编码体制，<br />惊世界上所有常用的文字都涵盖进去，从而减少个电脑商开发国外市场遇到的问题。<br />        这些编码系统也会互相冲突。也就是说，两种编码可能使用相同的数字代表两个不同的字符，或使用不同的数字代表相同的字符。任何<br />一台特定的计算机(特别是服务器)都需要支持许多不同的编码，但是，不论什么时候数据通过不同的编码或平台之间，那些数据总会有损坏<br />的危险。<br />    Unicode给每个字符提供了一个唯一的数字，不论是什么平台，不论是什么程序，不论什么语言。Unicode标准已经被这些工业界的领导<br />们所采用，例如：Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys和其它许多公司。最新的标准都需要<br />Unicode，例如XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML等等，并且，Unicode是实现ISO/IEC 10646的正规方式。许多<br />操作系统，所有最新的浏览器和许多其他产品都支持它。Unicode标准的出现和支持它工具的存在，是近来全球软件技术最重要的发展趋势。<br />       而Unicode4.0后有了UTF (Unicode/UCS Transformation Format),Unicode推荐使用UTF-8和UTF-16两种格式其中8和16指的是Bits数而不<br />是Bytes数。<br />UTF-16基本就是Unicode双字节的实现，加上一个应付未来需要的扩充编码机制（很少用）<br />UTF-8 是一种不等幅的编码方式，英数字（Ascii字码）保持原状，完全不受影响（因此不需要做转换），而其他汉字资料须透过程序来转换，<br />会[变胖]，因为每个字需要额外一个或两个Bytes来编码。<br />       下面我们来看看实战中我是如何做的：<br />    1.web.xml<br /> 配置过滤器<br /> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080">1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;!--</span>
				<span style="COLOR: #000000"> Filter Configuration </span>
				<span style="COLOR: #000000">--&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">filter</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">filter</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">name</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">Set Character Encoding</span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">filter</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">name</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">filter</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">cn.redstoneinfo.commons.web.EncodingFilter</span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">filter</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">  <br /></span>
				<span style="COLOR: #008080">5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">filter</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">6</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>    <br />    2.EncodingFilter.java：<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">这里设置的默认的编码,可以在web.xml中设置,如果不设就用这里的</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #008000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">protected</span>
				<span style="COLOR: #000000"> String encoding </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">UTF-8</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /></span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #0000ff">protected</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">boolean</span>
				<span style="COLOR: #000000"> ignore </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">true</span>
				<span style="COLOR: #000000">;<br /></span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_113_183_Open_Image" onclick="this.style.display='none'; Codehighlighter1_113_183_Open_Text.style.display='none'; Codehighlighter1_113_183_Closed_Image.style.display='inline'; Codehighlighter1_113_183_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_113_183_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_113_183_Closed_Text.style.display='none'; Codehighlighter1_113_183_Open_Image.style.display='inline'; Codehighlighter1_113_183_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span>
				<span id="Codehighlighter1_113_183_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_113_183_Open_Text">
						<span style="COLOR: #008000">/*</span>
						<span style="COLOR: #008000"> <br /></span>
						<span style="COLOR: #008080"> 7</span>
						<span style="COLOR: #008000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)<br /></span>
						<span style="COLOR: #008080"> 8</span>
						<span style="COLOR: #008000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />  </span>
						<span style="COLOR: #008000">*/</span>
				</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_254_649_Open_Image" onclick="this.style.display='none'; Codehighlighter1_254_649_Open_Text.style.display='none'; Codehighlighter1_254_649_Closed_Image.style.display='inline'; Codehighlighter1_254_649_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_254_649_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_254_649_Closed_Text.style.display='none'; Codehighlighter1_254_649_Open_Image.style.display='inline'; Codehighlighter1_254_649_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> init(FilterConfig filterConfig) </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> ServletException </span>
				<span id="Codehighlighter1_254_649_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_254_649_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080">10</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  String paramValue </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> filterConfig.getInitParameter(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">encoding</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /></span>
						<span style="COLOR: #008080">11</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_347_382_Open_Image" onclick="this.style.display='none'; Codehighlighter1_347_382_Open_Text.style.display='none'; Codehighlighter1_347_382_Closed_Image.style.display='inline'; Codehighlighter1_347_382_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_347_382_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_347_382_Closed_Text.style.display='none'; Codehighlighter1_347_382_Open_Image.style.display='inline'; Codehighlighter1_347_382_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (paramValue </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_347_382_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_347_382_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">12</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   </span>
								<span style="COLOR: #0000ff">this</span>
								<span style="COLOR: #000000">.encoding </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> paramValue;<br /></span>
								<span style="COLOR: #008080">13</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />  }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">14</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  String value </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> filterConfig.getInitParameter(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">ignore</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /></span>
						<span style="COLOR: #008080">15</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (value </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">null</span>
						<span style="COLOR: #000000">)<br /></span>
						<span style="COLOR: #008080">16</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   </span>
						<span style="COLOR: #0000ff">this</span>
						<span style="COLOR: #000000">.ignore </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">true</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">17</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (value.equalsIgnoreCase(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">true</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">))<br /></span>
						<span style="COLOR: #008080">18</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   </span>
						<span style="COLOR: #0000ff">this</span>
						<span style="COLOR: #000000">.ignore </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">true</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">19</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (value.equalsIgnoreCase(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">yes</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">))<br /></span>
						<span style="COLOR: #008080">20</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   </span>
						<span style="COLOR: #0000ff">this</span>
						<span style="COLOR: #000000">.ignore </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">true</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">21</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">22</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />   </span>
						<span style="COLOR: #0000ff">this</span>
						<span style="COLOR: #000000">.ignore </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">false</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">23</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> }</span>
				</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">24</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p> </p>
		<p>    3.Struts-config.xml:<br /> 设置资源文件的路径<br /> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080">1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">message</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">resources<br /></span>
				<span style="COLOR: #008080">2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  parameter</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">cn.redstoneinfo.oss.security.web.security-resource</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> key</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">SECURITY_RES</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">false</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  <br /></span>
				<span style="COLOR: #008080">4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">message</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">resources<br /></span>
				<span style="COLOR: #008080">5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  parameter</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">cn.redstoneinfo.oss.web.ApplicationResources</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">false</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">6</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>    4.role-list.jsp<br /> 页面编码和调用资源<br /> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;%</span>
				<span style="COLOR: #000000">@ page contentType</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">text/html; charset=UTF-8</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> language</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">java</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">%&gt;</span>
				<span style="COLOR: #000000"> <br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        <img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /><br /></span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">oss:panel label</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">security.role.list.title</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> bundle</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">SECURITY_RES</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">table width</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">100%</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">tr </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">tr1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> align</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">center</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> height</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">td width</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">5%</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">td</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">td </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">  <br /></span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">bean:message key</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">app.common.name</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">td</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">td </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">12</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">bean:message key</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">app.common.activeDate</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">13</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">td</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">14</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">td</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">15</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">bean:message key</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">app.common.inactiveDate</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">16</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">td </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">17</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">td</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">18</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">bean:message key</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">app.common.status</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">19</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">td</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">   <br /></span>
				<span style="COLOR: #008080">20</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    <br /></span>
				<span style="COLOR: #008080">21</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">tr</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">22</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        <img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /><br /></span>
				<span style="COLOR: #008080">23</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">input type</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">button</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> value</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">   &lt;bean:message key=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">app.common.</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">buttonnew</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> onclick</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">javascript:document.forms[0].act.value='add'; goUrlFormTarget('role.do', 'roleForm', 'roleTreeFrame');</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">    <br /></span>
				<span style="COLOR: #008080">24</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>
				<br />    5.ApplicationResources.properties<br /> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080">1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">app.common.name </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> 名字<br /></span>
				<span style="COLOR: #008080">2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> app.common.ip </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> IP<br /></span>
				<span style="COLOR: #008080">3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> app.common.port </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> 端口<br /></span>
				<span style="COLOR: #008080">4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> app.common.status </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> 状态 <br /></span>
				<span style="COLOR: #008080">5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>    6.build.xml<br /> 编译资源文件生成Unicode<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080">1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">native2ascii src</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">${oss.src.dir}</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> encoding</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">UTF-8</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> dest</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">${target.dir}/WEB-INF/classes</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">include name</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">**/*.properties</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #000000">&lt;/</span>
				<span style="COLOR: #000000">native2ascii</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">  <br /></span>
				<span style="COLOR: #008080">4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>    7.转换后的ApplicationResources.properties<br /> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080">1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">app.common.name </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> \u540d\u5b57<br /></span>
				<span style="COLOR: #008080">2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> app.common.ip </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> IP<br /></span>
				<span style="COLOR: #008080">3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> app.common.port </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> \u7aef\u53e3<br /></span>
				<span style="COLOR: #008080">4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> app.common.status </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> \u72b6\u6001<br /></span>
				<span style="COLOR: #008080">5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>    8.server.xml<br /> tomcat5.0以后post跟get提交方法不了不同的编码处理，应该用下面的方式来处理<br />     </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080">1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">Connector<br /></span>
				<span style="COLOR: #008080">2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  port</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">8080</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">               maxHttpHeaderSize</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">8192</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />               maxThreads</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">150</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> minSpareThreads</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> maxSpareThreads</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">75</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />               enableLookups</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">false</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> redirectPort</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">8443</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> acceptCount</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />               connectionTimeout</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">20000</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> disableUploadTimeout</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">true</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">  URIEncoding</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">UTF-8</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">6</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>    9.界面<br /><img height="131" alt="11.gif" src="http://www.blogjava.net/images/blogjava_net/fengtaishao/11.gif" width="387" border="0" /><br />    以上操作基本实现彻底消灭中文乱码问题，当然还有其他更好的办法和应用，我们这里只讲struts的简单应用中如何避免相应问题的处理办法。<br /></p>
<img src ="http://www.blogjava.net/liaojiyong/aggbug/67079.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2006-09-01 13:42 <a href="http://www.blogjava.net/liaojiyong/archive/2006/09/01/67079.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse+struts+Hibernate配置开发（转）</title><link>http://www.blogjava.net/liaojiyong/archive/2006/06/05/50452.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Mon, 05 Jun 2006 04:38:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2006/06/05/50452.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/50452.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2006/06/05/50452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/50452.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/50452.html</trackback:ping><description><![CDATA[这个手册只是为初学者制作的环境配置和快速开发的一些基本方法，为的是广大爱好者能快速上手，少走我走过的弯路，里面没有任何关于java模式和其他相关的说明。本人水平有限，也没有能力去讨论关于模式设计和开发细节的一些内容。 
<p></p><p></p><p>　　建议：<br /><br />　　如果你还不清楚struts和hibernate的一些基本原理，希望能先去了解一下这方面的相关内容。</p><p>　　推荐：<br /><br />　　Hibernate中文手册》作者认为要学Hibernate看这个就足够了，里面几乎包括了所有的细节，不过可能不太适合快速入门。<br /><br />　　地址：<a href="http://www.hibernate.org/hib_docs/v3/reference/zh-%20cn/html_single/">http://www.hibernate.org/hib_docs/v3/reference/zh- cn/html_single/</a><br /><br />　　关于struts的资料就很多了，这里推荐一个可以下载一些入门教程的网站。<br /><br />　　地址：<a href="http://www.wnetw.com/jclub/index.jsp">http://www.wnetw.com/jclub/index.jsp</a><br /><br />　　强烈建议入门的朋友先了解一下基本的原理！否则本文可能对你没有任何帮助。</p><p>　　相关工具下载：（注意版本）<br /><br />　　mysql5.0 <a href="http://www.mysql.org/">http://www.mysql.org</a><br />　　eclipse 3.1.1 <a href="http://www.eclipse.org/" target="_blank">http://www.eclipse.org</a><br />　　myeclipse4.0.3 <a href="http://www.myeclipseide.com/">http://www.myeclipseide.com</a><br />　　tomcat5.5</p><p>　　安装：<br /><br />　　关于tomcat和mysql的安装就不多说了，需要注意的是最好保证你的 jdk是1.5的版本，并配置好你的环境变量，不然可能会遇到一些问题。<br /><br />　　把eclipse解开，再去安装刚下载的myeclipse，在安装的时候需要把路径指定到刚才解开的eclipse上，由于myeclipse是个收费软件，所以需要注册。不过一般按照Chinese的习惯，去google一个注册码就可以了:}</p><p>　　开发环境部署：<br /><br />　　好了，现在保证你的mysql和tomcat服务能够正常启动，myeclipse能够正常打开（如果不能，可以去找一下相关的说明或者给作者留言）。下面我们就要开始真正的开始部署一个传说中的tomcat+struts+hibernate+mysql结构的工程了！（faint!前言就写的我好累）<br /><br />　　首先，在myeclipse里新建一个工程。在左边的Package Exporler面版里点右键选择new-&gt;project… <br /><br />　　在跳出菜单里选择MyEclipse-&gt;J2EE Projects-&gt;Web Project。<br /><br />　　点击next后进入如下画面：</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/3dv4s4cjwa2l.cn/pic/3fa10d830200006m" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/1.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/1.JPG" target="_blank"></a></p><p><br />　　工程名为：test<br /><br />　　结束后点击Finish。<br /><br />　　好了，如果成功的话你就会在 Package Exporler里看到一个新的test工程！现在我们先配置一下数据库方面的东西。首先在你的mysql 里建立一个数据库webases，再在里面新建一个表admin，里面三个字段分别为id,<a class="bluekey" href="http://www.yesky.com/key/99/160099.html" target="_blank">name</a>,password其中id为自动取值的主键（mysql具体的操作可以自己找资料，不是本文涉及范围）。<br /><br />　　再回到myeclipse ，选中window-&gt;Open Perspective-&gt;Other…<br /><br />　　可以看到现在跳出一个名为Select Perspective的菜单，在里面选中MyEclipse Databases Exporler，可以看到现在到了下面的页面。</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/2s5d31zdm346.cn/pic/3fa10d830200006n" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/2.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/2.JPG" target="_blank"></a></p><p>　　按以上图示输入相关字段后点击Finish便建立了一个数据库连接，在新出现的JDBC for Mysql上点右键，选择Open connection…，确认用户名和密码正确后点OK，如果一切顺利的话你会看到下面的画面： </p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/0g601v5hykhy.cn/pic/3fa10d830200006o" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/3.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/3.JPG" target="_blank"></a></p><p>　　这说明你已经和数据库建立了正确的连接。现在我们再回到window-&gt;Open Perspective- &gt;Other…里的MyEclipse，也就是我们刚进来的时候看到的画面。<br /><br />　　右键点击你刚建立的工程 test并选择MyEclipse-&gt;Add struts Capabilities…在跳出的菜单里按照如下输入并确定：</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/r8rfzry4u70v.cn/pic/3fa10d830200006p" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/4.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/4.JPG" target="_blank"></a></p><p>　　好了，现在你已经为你的工程增加了struts，接下来和上面一样在右键工程后选择MyEclipse- &gt;Add Hibernate Capabilities…一路确定下来为你的工程添加Hibernate。（为方便起见我们在选择路径时把HibernateSessionFactory.java放在了src/com下面，其实最好建立个单独的目录如 src/com/hibernate）<br /><br />　　为了更好的演示我们不建立通常的登陆页面而是建立个注册页面。选择 src目录下的hibernate.cfg.xml文件。照如下填写并保存。这样hibernate就为你建立了数据库的连接池。</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/w9r22908kj35.cn/pic/3fa10d830200006q" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/5.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/5.JPG" target="_blank"></a></p><p>　　下面我们再选择WebRoot/WEB-INF/struts-config.xml文件，在画面中点击右键选择new- &gt;Form, Action and JSP。如下填写</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/w0cu77s737rz.cn/pic/3fa10d830200006r" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/6.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/6.JPG" target="_blank"></a><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/5.JPG" target="_blank"></a></p><p>　　再选择JSP选项，如下</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/1x6mi889p265.cn/pic/3fa10d830200006s" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/7.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/7.JPG" target="_blank"></a><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/6.JPG" target="_blank"></a></p><p>　　最后选择Finish。<br /><br />　　再新建一个一个success.jsp的页面，<br /><br />　　在刚才struts- config.xml文件里右键<a class="bluekey" href="http://www.yesky.com/key/1712/156712.html" target="_blank">选择a</a>ddAdmin选择Properties，在菜单里选择Forwords，再点add，如下图填写 </p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/55rct6wh32c3.cn/pic/3fa10d830200006t" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/8.JPG" target="_blank"></a></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/8.JPG" target="_blank"></a><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/7.JPG" target="_blank"></a></p><p>　　最后你的struts-config.xml就是下面这个样子：</p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/9.JPG" target="_blank"></a><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/8.JPG" target="_blank"></a></p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/17nf5q9p44y5.cn/pic/3fa10d830200006u" /></p><p><br />　　下面我们转到hibernate。换到刚才我们建立数据库的页面，选择你的admin的表点右键选择Create Hibernate Mapping。选择好打包路径后选择Finish。如图：</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/k8h07y72ok59.cn/pic/3fa10d830200006v" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/10.JPG" target="_blank"></a></p><p>　　在你刚才选择的路径下（我为方便是src/com/yourcompanyname/）下新建立的文件 AdminDAOFactory.java文件并输入以下内容：</p><p>package com.yourcompanyname;</p><p>import java.util.Iterator;</p><p>import org.hibernate.HibernateException;<br />import org.hibernate.Query;<br />import org.hibernate.Session;<br />import org.hibernate.Transaction;</p><p>import com.hibernate.SessionFactory;</p><p>public class AdminDAOFactory {<br /> Session session;<br /> Transaction tx;<br /> public void add(Admin admin) throws HibernateException {<br />  /**<br />   * Creation Date: 11-17-2005<br />   * TODO Add a new admin user.<br />   * @param An object of Admin<br />   * @return void<br />   * @author Coder Guo<br />   */<br />  try {<br />   session = SessionFactory.currentSession();<br />   tx = session.beginTransaction();<br />   //Add a new admin<br />   session.save(admin);<br />   tx.commit ();<br />  }catch(HibernateException e){<br />   throw e;<br />  }finally{<br />   if (tx!=null) {<br />    tx.rollback();<br />   } <br />   SessionFactory.closeSession();<br />  }<br /> }<br />}</p><p> 再打开com.yourcompany.struts.action下的AddAdminAction.java添加（其中如果有错误选中好按ctrl+shift+o自动添加包）</p><p>public class AddAdminAction extends Action {</p><p> // --------------------------------------------------------- Instance Variables</p><p> // --------------------------------------------------------- Methods</p><p> /** <br />  * Method execute<br />  * @param mapping<br />  * @param form<br />  * @param request<br />  * @param response<br />  * @return ActionForward<br />  * @author Coder Guo<br />  */<br /> public ActionForward execute(<br />  ActionMapping mapping,<br />  ActionForm form,<br />  HttpServletRequest request,<br />  HttpServletResponse response) {<br />  AddAdminForm addAdminForm = (AddAdminForm) form;<br />  <br />  // TODO Add a new admin<br />  Admin admin = new Admin();<br />  admin.setName(addAdminForm.getName ());<br />  admin.setPassword(addAdminForm.getPassword ());<br />  AdminDAOFactory adminDAO = new AdminDAOFactory ();<br />  adminDAO.add(admin);<br />  <br />  return mapping.findForward("success");<br /> }</p><p>}</p><p> 再打开com.yourcompanyname.struts.form下的AddAdminForm.java，修改（如果有错误按照上面说的方法导入包）<br /> public ActionErrors validate(<br />  ActionMapping mapping,<br />  HttpServletRequest request) {</p><p>  // TODO Auto-generated method stub<br />  ActionErrors errors = new ActionErrors();<br />  <br />  Session session = SessionFactory.currentSession();<br />  Transaction tx = session.beginTransaction ();<br />  Query query = session.createQuery("select admin from Admin as admin where admin.name = '" + this.name + "'");<br />  Iterator it = query.iterate ();<br />  if (it.hasNext()){<br />   errors.add ("addAdmin.err.name",new ActionMessage("form.addAdmin.err.name"));<br />  } <br />  tx.commit();<br />  SessionFactory.closeSession ();<br />  return errors;<br /> }</p><p> public void reset(ActionMapping mapping, HttpServletRequest request) {</p><p>  // TODO Auto-generated method stub<br />  this.name=null;<br />  this.password=null;<br /> }</p><p>　　再打开com\yourcompanyname\struts下的ApplicationResource.properties在这里面添加错误信息： <br /><br />Form.addAdmin.err.name=err</p><p>　　最后，（汗，好累啊-_-!）打开addAdmin.jsp修改成如下：<br /><br />&lt;%@ page contentType="text/html; charset=utf-8"%&gt; <br />&lt;%@ page language="java"%&gt;<br />&lt;%@ taglib uri="<a href="http://jakarta.apache.org/struts/tags-bean">http://jakarta.apache.org/struts/tags-bean</a>" prefix="bean"%&gt; <br />&lt;%@ taglib uri="<a href="http://jakarta.apache.org/struts/tags-html">http://jakarta.apache.org/struts/tags-html</a>" prefix="html"%&gt;</p><p>&lt;script language = "javascript"&gt;<br />&lt;!--<br />function <a class="bluekey" href="http://www.yesky.com/key/4908/159908.html" target="_blank">check</a>(){<br /> if (loginForm.userName.value == "" || loginForm.password.value == ""){<br />  alert("请输入完整的信息！");<br />  loginForm.userName.focus();<br />  return false;<br /> }<br />}<br />//--&gt;<br />&lt;/script&gt;<br /> <br /> &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;<br />&lt;html:html&gt;<br />  &lt;head&gt;<br />    &lt;html:base /&gt;<br />    <br />    &lt;title&gt;login.jsp&lt;/title&gt;<br />    &lt;link href="css/webcss.css" rel="stylesheet" type="text/css"&gt;<br />    <br />    &lt;<a class="bluekey" href="http://www.yesky.com/key/4816/159816.html" target="_blank">meta</a> http-equiv="pragma" content="no- cache"&gt;<br />    &lt;meta http-equiv="cache-control" content="no- cache"&gt;<br />    &lt;meta http-equiv="expires" content="0"&gt;    <br />    &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;<br />    &lt;meta http- equiv="description" content="This is my page"&gt;<br />  &lt;/head&gt;<br />  </p><p>  &lt;body&gt;<br />  &lt;center&gt;<br />   &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />   &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />   &lt;table width="<a class="bluekey" href="http://www.yesky.com/key/636/160636.html" target="_blank">30</a>0" border="0" cellpadding="0" cellspacing="0"&gt;<br />   &lt;html:form action="/addAdmin" focus="name" method="GET"&gt;<br />     &lt;tr align="center" valign="middle"&gt;<br />       &lt;td colspan="2" class="typt_normal"&gt;新增管理员&lt;/td&gt;<br />     &lt;/tr&gt;<br />     &lt;tr&gt;<br />       &lt;td width="100" align="center" valign="middle" class="typt_normal"&gt;名称： &lt;/td&gt;<br />       &lt;td width="200" align="left"&gt;&lt;html:text property="name" styleClass="text_s"/&gt;&lt;html:errors property="addAdmin.err.name"/&gt;&lt;/td&gt;<br />     &lt;/tr&gt;<br />     &lt;tr&gt;<br />       &lt;td width="100" align="center" valign="middle" class="typt_normal"&gt;密码： &lt;/td&gt;<br />       &lt;td width="200" align="left"&gt;&lt;html:password property="password" styleClass="text_s"/&gt;&lt;/td&gt;<br />     &lt;/tr&gt;<br />     &lt;tr&gt; <br />       &lt;td colspan="2" align="center" valign="middle"&gt;&lt;html:submit value="提交" onclick="return check ();"/&gt;&lt;html:reset value="重置"&gt;&lt;/html:reset&gt;&lt;/td&gt;<br />       &lt;/tr&gt;<br /> &lt;/html:form&gt;<br />   &lt;/table&gt;<br /> &lt;/center&gt;<br /> &lt;/body&gt;</p><p>&lt;/html:html&gt;<br /><br />　　其中可以看到如何在struts的标签中使用javascript的方法。<br /><br />　　配置好myeclipse于tomcat的连接。在window-&gt;Preferences做如下设定：</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/rfe9mz6n6877.cn/pic/3fa10d830200006w" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/11.JPG" target="_blank"></a></p><p>　　在项目文件点右键－&gt;“myeclipse”－&gt;“Add and remove project deployment”，如下图：</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/4el6k0a08339.cn/pic/3fa10d830200006x" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/12.JPG" target="_blank"></a></p><p>　　好了，我们的配置工作基本结束了,在myeclipse上开启tomcat服务</p><p align="center"><img src="http://dev.yesky.com/imagelist/05/12/a597a7j21uhi.cn/pic/3fa10d830200006y" /></p><p><a href="file:///E:/我的文章/MyEclipse+TomCat+struts+Hibernate+Mysql环境配置手册和快速开发实例/pic/13.JPG" target="_blank"></a></p><p>　　现在打开浏览器，输入<br /><br />　　<a href="http://127.0.0.1:8080/test/addAdmin.jsp">http://127.0.0.1:8080/test/addAdmin.jsp</a><b r="">就可以看到你的jsp页面了！</b></p><img src ="http://www.blogjava.net/liaojiyong/aggbug/50452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2006-06-05 12:38 <a href="http://www.blogjava.net/liaojiyong/archive/2006/06/05/50452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在struts框架下实现文件的上传 (转)</title><link>http://www.blogjava.net/liaojiyong/archive/2006/05/23/47693.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Tue, 23 May 2006 10:03:00 GMT</pubDate><guid>http://www.blogjava.net/liaojiyong/archive/2006/05/23/47693.html</guid><wfw:comment>http://www.blogjava.net/liaojiyong/comments/47693.html</wfw:comment><comments>http://www.blogjava.net/liaojiyong/archive/2006/05/23/47693.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liaojiyong/comments/commentRss/47693.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liaojiyong/services/trackbacks/47693.html</trackback:ping><description><![CDATA[
		<div class="postText">
				<div class="postText">
						<p>由于jspsmartupload上传文件，当前端页面没有file控件时，后端用jspsmartupload控件upload时将会走入一个死循环。现在采用struts自己提供的功能实现文件的上传。<br />1、前端页面upload.jsp<br />&lt;html:form action="/filesave.do" styleId="formItem" method="post"  enctype="multipart/form-data"&gt;<br />&lt;INPUT  class='input-file' type="file" name="<span style="COLOR: red">theFile</span>"&gt;<br />&lt;/html:form&gt;<br />2、struts-config.xml文件配置<br />&lt;form-bean name="UploadForm" type="yhp.test.web.UploadForm" /&gt;<br />&lt;action input="/upload.jsp" name="UploadForm"   path="/filesave" scope="request" type="yhp.test.web.UploadAction" validate="false"&gt;<br />      &lt;forward name="success" path="/success.jsp" /&gt;<br />      &lt;forward name="error" path="/error.jsp" /&gt;<br />    &lt;/action&gt;<br />3、UploadForm.java文件<br />package yhp.test.web;</p>
						<p>import org.apache.struts.upload.FormFile;<br />import org.apache.struts.action.ActionForm;</p>
						<p>public class UploadForm extends ActionForm {<br />  protected String theText;   //使用protected ,其它需要上传的form可以继承此form<br />  protected boolean writeFile = true;<br />  protected FormFile <span style="COLOR: red">theFile</span>;<br />  protected String filePath;</p>
						<p>  public String getTheText() {<br />    return theText;<br />  }<br />  public void setTheText(String theText) {<br />    this.theText = theText;<br />  }<br />  public FormFile getTheFile() {<br />    return theFile;<br />  }<br />  public void setTheFile(FormFile theFile) {<br />    this.theFile = theFile;<br />  }<br />  public void setWriteFile(boolean writeFile) {<br />    this.writeFile = writeFile;<br />  }<br />  public boolean getWriteFile() {<br />    return writeFile;<br />  }<br />  public void setFilePath(String filePath) {<br />    this.filePath = filePath;<br />  }<br />  public String getFilePath() {<br />    return filePath;<br />  }<br />  public void reset() {<br />    writeFile = false;<br />  }<br />}<br /><br />4、UploadAction.java文件<br />package yhp.test.web;</p>
						<p>import java.io.ByteArrayOutputStream;<br />import java.io.File;<br />import java.io.FileNotFoundException;<br />import java.io.FileOutputStream;<br />import java.io.IOException;<br />import java.io.InputStream;<br />import java.io.OutputStream;<br />import java.util.Date;<br />import javax.servlet.http.HttpServletRequest;<br />import javax.servlet.http.HttpServletResponse;</p>
						<p>import org.apache.struts.action.Action;<br />import org.apache.struts.action.ActionForm;<br />import org.apache.struts.action.ActionForward;<br />import org.apache.struts.action.ActionMapping;<br />import org.apache.struts.upload.FormFile;</p>
						<p>
								<br />public class UploadAction extends Action {<br />  public ActionForward execute(ActionMapping actionMapping,<br />                               ActionForm actionForm,<br />                               HttpServletRequest httpServletRequest,<br />                               HttpServletResponse httpServletResponse) throws<br />      Exception {<br />    if (actionForm instanceof UploadForm) {<br />      // 获取上传的目录<br />      String path = getServlet().getServletContext().getInitParameter("UPLOADPATH");<br />      File f = new File(path);<br />      if (!f.isDirectory()) {<br />        f.mkdir();<br />      }</p>
						<p>      UploadForm theForm = (UploadForm) actionForm;<br />      String text = theForm.getTheText();<br />      FormFile file = theForm.getTheFile();<br />      String fileName = file.getFileName();<br />      String contentType = file.getContentType();<br />      boolean writeFile = theForm.getWriteFile();<br />      String desFileName=path fileName ;<br />      String size = (file.getFileSize() + " bytes");<br />      try {<br />          InputStream stream = file.getInputStream();<br />   OutputStream bos = new FileOutputStream(strFileName);          <br />          byte[] buffer = new byte[file.getFileSize()];<br />          stream.read(buffer);<br />          bos.write(buffer);<br />   stream.close(); <br />          bos.close();<br />          return actionMapping.findForward("success");<br />      }<br />      catch (FileNotFoundException fnfe) {<br />          return actionMapping.findForward("success");<br />      }<br />      catch (IOException ioe) {<br />          return actionMapping.findForward("success");<br />      }<br />      catch(Exception eo){<br />          return actionMapping.findForward("error");<br />      } <br />    }else{<br />      return actionMapping.findForward("error");<br />    }<br />  }<br />}<br /></p>
				</div>
		</div>
<img src ="http://www.blogjava.net/liaojiyong/aggbug/47693.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liaojiyong/" target="_blank">liaojiyong</a> 2006-05-23 18:03 <a href="http://www.blogjava.net/liaojiyong/archive/2006/05/23/47693.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>