﻿<?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-caike-随笔分类-SpringFramework</title><link>http://www.blogjava.net/caike/category/6258.html</link><description>优秀是一种习惯，生命是一种过程，两点之间最短的距离并不一定是直线，只有知道如何停止的人才知道如何加快</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 03:45:27 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 03:45:27 GMT</pubDate><ttl>60</ttl><item><title>使用jodd form简化SpringMVC中Controller的配置</title><link>http://www.blogjava.net/caike/archive/2005/12/23/25158.html</link><dc:creator>caike</dc:creator><author>caike</author><pubDate>Fri, 23 Dec 2005 01:50:00 GMT</pubDate><guid>http://www.blogjava.net/caike/archive/2005/12/23/25158.html</guid><wfw:comment>http://www.blogjava.net/caike/comments/25158.html</wfw:comment><comments>http://www.blogjava.net/caike/archive/2005/12/23/25158.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/caike/comments/commentRss/25158.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caike/services/trackbacks/25158.html</trackback:ping><description><![CDATA[<p class="MsoNormal"><span lang="EN-US">Jodd</span><span style="font-family: 宋体;">是一个开源项目，</span><span style="color: black;" lang="EN-US"><a href="http://jodd.sourceforge.net/">http://jodd.sourceforge.net</a></span><span style="font-family: 宋体; color: black;">，</span><span style="font-family: 宋体;">有一个好用的</span><span lang="EN-US">jsp</span><span style="font-family: 宋体;">标签，可以大大简化有表单输入的</span><span lang="EN-US">controller</span><span style="font-family: 宋体;">。</span></p>

<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><b style=""><span style="font-size: 16pt; font-family: 宋体;">使用</span></b><b style=""><span style="font-size: 16pt;" lang="EN-US">Jodd</span></b><b style=""><span style="font-size: 16pt; font-family: 宋体;">的优点：</span></b><b style=""><span style="font-size: 16pt;" lang="EN-US"><o:p></o:p></span></b></p>

<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">1.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 
</span></span></span><!--[endif]--><span style="font-family: 宋体;">简化和统一</span><span lang="EN-US">controller</span><span style="font-family: 宋体;">，抛弃</span><span lang="EN-US">extends SimpleFormController</span><span style="font-family: 宋体;">，统一使用</span><span lang="EN-US">implements Controller</span><span style="font-family: 宋体;">的方式。</span></p>

<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">2.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
</span></span></span><!--[endif]--><span style="font-family: 宋体;">简化</span><span lang="EN-US">JSP</span><span style="font-family: 宋体;">页面的</span><span lang="EN-US">bind,</span><span style="font-family: 宋体;">不需要一个字段一个字段的绑定。</span></p>

<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">3.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 
</span></span></span><!--[endif]--><span style="font-family: 宋体;">对</span><span lang="EN-US">bean</span><span style="font-family: 宋体;">没有任何要求，可以使用任意的</span><span lang="EN-US">bean</span><span style="font-family: 宋体;">做为</span><span lang="EN-US">formBean.</span></p>

<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><b style=""><span style="font-size: 16pt; font-family: 宋体;">使用方法简介：</span></b><b style=""><span style="font-size: 16pt;" lang="EN-US"><o:p></o:p></span></b></p>

<p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">１．</span></span><!--[endif]--><span style="font-family: 宋体;">把</span><span lang="EN-US">jodd.jar</span><span style="font-family: 宋体;">放到</span><span lang="EN-US">web-inf-&gt;lib</span><span style="font-family: 宋体;">下，在</span><span lang="EN-US">web.xml</span><span style="font-family: 宋体;">里声名标签：</span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"></span></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jodd</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/lib/jodd.jar</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br></span></div><p class="MsoNormal"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">２．</span></span><!--[endif]--><span style="font-family: 宋体;">任意的一个</span><span lang="EN-US">javaBean做为FormBean</span></p>

<p class="MsoNormal"><span lang="EN-US"></span></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);">&nbsp;caike;&nbsp;<br><br></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;User&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;String&nbsp;userName;&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;String&nbsp;password;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;String&nbsp;getPassword()&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;password;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;setPassword(String&nbsp;pwd)&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.password&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;pwd;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;String&nbsp;getUserName()&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;userName;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;setUserName(String&nbsp;username)&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.userName&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;username;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;<br><br>}<br></span></div><p class="MsoNormal"><span lang="EN-US"></span></p>

<p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">３．</span></span><!--[endif]--><span style="font-family: 宋体;">在</span><span lang="EN-US">JSP</span><span style="font-family: 宋体;">页面使用</span><span lang="EN-US">jodd tag:,</span><span style="font-family: 宋体;">比如对应用户登录页面的</span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"></span></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&lt;%</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">@page&nbsp;import</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">caike.User</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"><br><br></span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&lt;%</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">@taglib&nbsp;uri</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">jodd</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;prefix</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">jodd</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"></span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);"></span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;<br><br></span><font color="#ff0000" size="4"><b><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jodd:form&nbsp;</span><span style="color: rgb(255, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">="user"</span><span style="color: rgb(255, 0, 0);">&nbsp;scopes</span><span style="color: rgb(0, 0, 255);">="session"</span><span style="color: rgb(0, 0, 255);">&gt;</span></b></font><span style="color: rgb(0, 0, 0);"><br><br></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">form&nbsp;</span><span style="color: rgb(255, 0, 0);">action</span><span style="color: rgb(0, 0, 255);">="my.htm"</span><span style="color: rgb(255, 0, 0);">&nbsp;method</span><span style="color: rgb(0, 0, 255);">="post"</span><span style="color: rgb(255, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">table&nbsp;</span><span style="color: rgb(255, 0, 0);">width</span><span style="color: rgb(0, 0, 255);">="300"</span><span style="color: rgb(255, 0, 0);">&nbsp;border</span><span style="color: rgb(0, 0, 255);">="0"</span><span style="color: rgb(255, 0, 0);">&nbsp;cellspacing</span><span style="color: rgb(0, 0, 255);">="0"</span><span style="color: rgb(255, 0, 0);">&nbsp;cellpadding</span><span style="color: rgb(0, 0, 255);">="0"</span><span style="color: rgb(255, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;align</span><span style="color: rgb(0, 0, 255);">="center"</span><span style="color: rgb(255, 0, 0);">&nbsp;class</span><span style="color: rgb(0, 0, 255);">="white"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> &nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td&nbsp;</span><span style="color: rgb(255, 0, 0);">height</span><span style="color: rgb(0, 0, 255);">="32"</span><span style="color: rgb(255, 0, 0);">&nbsp;align</span><span style="color: rgb(0, 0, 255);">="right"</span><span style="color: rgb(255, 0, 0);">&nbsp;width</span><span style="color: rgb(0, 0, 255);">="107"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">用户名：</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td&nbsp;</span><span style="color: rgb(255, 0, 0);">height</span><span style="color: rgb(0, 0, 255);">="32"</span><span style="color: rgb(255, 0, 0);">&nbsp;width</span><span style="color: rgb(0, 0, 255);">="193"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">input&nbsp;</span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="text"</span><span style="color: rgb(255, 0, 0);">&nbsp;name</span><span style="color: rgb(0, 0, 255);">="userName"</span><span style="color: rgb(255, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class</span><span style="color: rgb(0, 0, 255);">="input"</span><span style="color: rgb(255, 0, 0);">&nbsp;size</span><span style="color: rgb(0, 0, 255);">="20"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td&nbsp;</span><span style="color: rgb(255, 0, 0);">height</span><span style="color: rgb(0, 0, 255);">="33"</span><span style="color: rgb(255, 0, 0);">&nbsp;align</span><span style="color: rgb(0, 0, 255);">="right"</span><span style="color: rgb(255, 0, 0);">&nbsp;width</span><span style="color: rgb(0, 0, 255);">="107"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">密码：</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td&nbsp;</span><span style="color: rgb(255, 0, 0);">height</span><span style="color: rgb(0, 0, 255);">="33"</span><span style="color: rgb(255, 0, 0);">&nbsp;width</span><span style="color: rgb(0, 0, 255);">="193"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">input&nbsp;</span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="password"</span><span style="color: rgb(255, 0, 0);">&nbsp;name</span><span style="color: rgb(0, 0, 255);">="password"</span><span style="color: rgb(255, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class</span><span style="color: rgb(0, 0, 255);">="input"</span><span style="color: rgb(255, 0, 0);">&nbsp;size</span><span style="color: rgb(0, 0, 255);">="21"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">td&nbsp;</span><span style="color: rgb(255, 0, 0);">height</span><span style="color: rgb(0, 0, 255);">="69"</span><span style="color: rgb(255, 0, 0);">&nbsp;align</span><span style="color: rgb(0, 0, 255);">="center"</span><span style="color: rgb(255, 0, 0);">&nbsp;colspan</span><span style="color: rgb(0, 0, 255);">="2"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">input&nbsp;</span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="submit"</span><span style="color: rgb(255, 0, 0);">&nbsp;name</span><span style="color: rgb(0, 0, 255);">="Submit"</span><span style="color: rgb(255, 0, 0);">&nbsp;value</span><span style="color: rgb(0, 0, 255);">="登录"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">table</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">form</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><br></span><b><font size="4"><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jodd:form</span><span style="color: rgb(0, 0, 255);">&gt;</span></font></b><span style="color: rgb(0, 0, 0);"><br></span></div><p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: red; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: red; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">４．</span></span><!--[endif]--><span lang="EN-US">Dispatch-servelt.xml</span><span style="font-family: 宋体;">中对</span><span lang="EN-US">controller</span><span style="font-family: 宋体;">的配置</span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: red; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US">&lt;bean id="myController"
class="caike.MyController"&gt;<span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: red; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp; </span>&lt;/bean&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: red;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: 宋体; color: black;">不再需要这种方式：</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp; </span></span><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US">&lt;!-- </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;bean
id="myController" class="caike.MyFormController"&gt;<span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;property
name="commandClass" value="caike" /&gt;<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;property
name="formView" value="userForm" /&gt;<span style="">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: left;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/bean&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp; </span>--&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US"><o:p></o:p></span></p>

<p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt;"><!--[if !supportLists]--><span style="" lang="EN-US"><span style="">５．</span></span><!--[endif]--><span style="font-family: 宋体;">在</span><span lang="EN-US">controller</span><span style="font-family: 宋体;">中取出</span><span lang="EN-US">user</span></p>

<p class="MsoNormal"><span lang="EN-US"></span></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);">&nbsp;caike;&nbsp;<br><br></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;javax.servlet.http.HttpServletRequest;<br><br></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;javax.servlet.http.HttpServletResponse;&nbsp;<br><br></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;jodd.bean.BeanUtil;&nbsp;<br><br></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;org.springframework.web.servlet.ModelAndView;<br><br></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;org.springframework.web.servlet.mvc.Controller;<br><br>&nbsp;<br><br></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;MyController&nbsp;</span><span style="color: rgb(0, 0, 255);">implements</span><span style="color: rgb(0, 0, 0);">&nbsp;Controller&nbsp;{<br><br>&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;ModelAndView&nbsp;handleRequest(HttpServletRequest&nbsp;request,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpServletResponse&nbsp;response)&nbsp;</span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);">&nbsp;Exception&nbsp;{<br><br>&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User&nbsp;user&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;User();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BeanUtil.load(user,&nbsp;request);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">用户名:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;user.getUserName()&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;密码:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;user.getPassword());<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;<br><br>}<br></span></div><p class="MsoNormal"><span lang="EN-US"></span></p>

<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><b style=""><span style="font-size: 16pt; font-family: 宋体;">需要注意的地方：</span></b><b style=""><span style="font-size: 16pt;" lang="EN-US"><o:p></o:p></span></b></p>

<p class="MsoNormal"><span style="font-family: 宋体;">表单中对应的名字</span><span lang="EN-US">name</span><span style="font-family: 宋体;">和</span><span lang="EN-US">javaBean</span><span style="font-family: 宋体;">里对应的属性名要相同。</span></p>

<p class="MsoNormal" style="margin-left: 5pt; text-align: left; text-indent: -5pt;" align="left"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US">&lt;input
type="text" </span><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: red; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US">name="userName"</span></p>

<p class="MsoNormal"><span style="background: white none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>class="input"
size="20"&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);" lang="EN-US"><o:p></o:p></span></p>



<p class="MsoNormal"><span lang="EN-US">public class User {<o:p> <br></o:p></span></p>

<p class="MsoNormal"><span lang="EN-US"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private
String userName;</span></p><p class="MsoNormal"><span lang="EN-US">.......<br></span></p>

<p class="MsoNormal"><font size="5"><b><span lang="EN-US"><o:p>&nbsp;参考：<br></o:p></span></b></font></p><p class="MsoNormal"><span lang="EN-US">http://www.blogjava.net/calvin/archive/2005/08/24/10914.html</span></p><p class="MsoNormal"><a id="_f9f3336a0f89507a_HomePageDays_DaysList__ctl31_DayItem_DayList__ctl1_TitleUrl" href="../../calvin/archive/2005/08/24/10914.html">　<span></span></a><a id="Header2_HeaderTitle" href="../../calvin/">花钱的年华</a><a id="_f9f3336a0f89507a_HomePageDays_DaysList__ctl31_DayItem_DayList__ctl1_TitleUrl" href="../../calvin/archive/2005/08/24/10914.html">　　　简化Spring(4)--View层</a></p>

<img src ="http://www.blogjava.net/caike/aggbug/25158.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caike/" target="_blank">caike</a> 2005-12-23 09:50 <a href="http://www.blogjava.net/caike/archive/2005/12/23/25158.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>