springMVC入门

<div class="it610-blog-content-contain" style="font-size: 14px;">
<p> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">转载自:http://blog.csdn.net/lenotang/article/details/2562348</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">作为一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">J2EE</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的开发者,我们基本上是开发基于</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">WEB</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的应用系统。事实上,工作流,状态管理以及验证都是需要解决的重要功能。而</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">HTTP</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">协议的无状态性决定了这些功能都不容易实现。</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Spring</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">WEB</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">框架就是来帮助我们解决这些问题的。使用</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Spring</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,我们可以让</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">WEB</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">框架自动将传递进来的请求参数填充到模型对象中,同时提供验证和错误处理。还可以管理用户在</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">WEB</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">表单中创建的对象的状态。在了解</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">之前,我们先来复习下</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">MVC.</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">MVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">从逻辑上把应用分为模型组件,视图组件和控制器组件。其中控制器组件又可以细分为:前端控制器组件和后端控制器组件。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">我们来看一下</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">MVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的基本工作流程:</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-family: 宋体;"><span style="margin: 0px; padding: 0px; font-size: small;">首先是客户端(通常是浏览器)发出一个请求。第一个接受这个请求的组件一般是一个前端控制器。它将不同的请求交给不同的后端控制器来处理,而在后端控制器里面又可以调用相应的模型对象来处理具体的业务逻辑,最后再返回一个特定的视图响应给客户端。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">怎么理解</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">MVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">呢?我们举一个现实的例子,前段时间地震太可怕了,全国人民都在上下一心抗震救灾。我们敬爱的温*理给武警司令下命令让他完成抗震救灾的艰巨任务,于是武警司令就根据各地情况派遣不同类型的特种兵到不同的地区去,然后特种兵使用大大小小的工具完成了任务,最后上交给司令一份统计图表,司令再上交给温*理。我们就来分析一下,这符不符合</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">MVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的设计模式。这里呢,温*理就是客户端,武警司令就是前端控制器,特种兵就是后端控制器,特种兵所使用的工具就是模型,最后上交的统计图表就是视图。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">现在大家应该可以理解</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">MVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的设计思想了。拿我们比较熟悉的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">struts</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">框架来说,前端控制器就是</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ActionServlet,</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">后端控制器就是</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Action.</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">请求的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">和后端控制器的映射关系在</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">struts-config.xml</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">上的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">&lt;action-mappings&gt;</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">里面配置,模型对象就是我们平常写的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DAO/DTO</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,返回的视图类型一般就是</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">jsp</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">了。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal; text-indent: 21pt;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">那么,在</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">spring MVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">中又是怎样的呢</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">?</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,我们先按上面对号入座地说一下。第一个接受这个请求的前端控制器叫</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,后端控制器叫</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Controller</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">。负责处理请求</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">和后端控制器映射的叫</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">HandMapping</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,它有多种类型,比较灵活,也是在一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">xml</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">文件上进行配置。负责业务逻辑处理的模型对象一般也是我们平常写的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DAO/DTO</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">组件。只是它最后的返回更灵活,</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Controller</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">返回一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ModelAndView</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">对象给</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ModelAndView</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">可以携带一个视图对象,也可以携带一个视图对象的逻辑名。如果携带的是一个视图对象的逻辑名,那</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">需要一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ViewResolver</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">来查找用于渲染回应的视图对象。最后,</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">将请求分派给</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ModelAndView</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">对象指定的视图对象。视图对象负责渲染返回给客户的回应。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">我们学习知识,一样要注意运用类比迁移的方法。有人说,我学会了</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">struts</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">,但学不会</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">springMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">。这是说不过去的。因为二者的思想完全一致。所以,我们只需要学习它们不一样的地方就可以啦。好,我们现在先跑一个最简单的例子,让大家对构建</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的基本步骤有个直观的认识。大家要边跑边跟</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">struts</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">做比较。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(1)</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">建立动态</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">web</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">工程,导入</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">spring</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">的</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">jar</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">包。</span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(2)</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">配置</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">是</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的核心,将下面</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Servlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的注册信息登记在</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">web.xml</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">中。一定要记住:</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Servlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">跟伴侣一样,要结婚,先得注册登记!</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #ff6600; font-family: 'Courier New';" lang="EN-US">test</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-class</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">org.springframework.web.servlet.DispatcherServlet</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-class</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">load-on-startup</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">1</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">load-on-startup</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-mapping</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">test</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">url-pattern</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">*.do</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">url-pattern</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">servlet-mapping</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(3)</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">编写</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Controller</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">,做核心配置文件,并配置</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">url</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">和</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Controller</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">的映射</span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">package</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> com.wepull.test;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; font-family: 'Courier New';" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">import</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> javax.servlet.http.HttpServletRequest;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">import</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> javax.servlet.http.HttpServletResponse;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; font-family: 'Courier New';" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">import</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> org.springframework.web.servlet.ModelAndView;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">import</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> org.springframework.web.servlet.mvc.Controller;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; font-family: 'Courier New';" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">public</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">class</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> <span style="margin: 0px; padding: 0px; background-color: silver;">HelloController</span> </span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">implements</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> Controller{</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">    </span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">public</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> ModelAndView handleRequest(HttpServletRequest request,</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">           </span><span style="margin: 0px; padding: 0px;">   </span>HttpServletResponse response) </span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">throws</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> Exception {</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">           </span><span style="margin: 0px; padding: 0px;">  </span>request.setAttribute(</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"hello"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">, </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"welcome to spring!"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">);</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">           </span><span style="margin: 0px; padding: 0px;">  </span></span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">return</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f0055; font-family: 'Courier New';" lang="EN-US">new</span></strong><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> ModelAndView(</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: red; font-family: 'Courier New';" lang="EN-US">welcome</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">);</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">           </span><span style="margin: 0px; padding: 0px;"> </span>}</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">}</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">我们知道</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">Struts</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">有个</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">XML</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">格式的核心配置文件,</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">springMVC</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">当然也有,在</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">WEB-INF</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">下新建一</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">XML</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">文件</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">:</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: red; font-family: 'Courier New';" lang="EN-US">test</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">-servlet.xml.</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">注意,这里的</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">test</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">取决于</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">servlet</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">的名字</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">.</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">当</span><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">载入后,它将试图从这个文件中载入应用上下文。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;?</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">xml </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">version</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"1.0" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">encoding</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"UTF-8"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">?&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;!</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">DOCTYPE </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: navy; font-family: 'Courier New';" lang="EN-US">beans </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: gray; font-family: 'Courier New';" lang="EN-US">PUBLIC </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: navy; font-family: 'Courier New';" lang="EN-US">"-//SPRING//DTD BEAN//EN"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f5f; font-family: 'Courier New';" lang="EN-US">"http://www.springframework.org/dtd/spring-beans.dtd"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">beans</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">    </span>&lt;!--</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 宋体;">缺省映射处理器,不需要明确声明,但声明后就非常清楚使用的是哪个映射处理器</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">  </span>--&gt;<span style="margin: 0px; padding: 0px;">   </span>&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">bean</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">id</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"beanNameUrlMapping"</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">    </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">class</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">    </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">bean</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">    </span>&lt;!-- </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 宋体;">这里的</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 宋体;">属性有两个职责,既定义</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">Bean</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 宋体;">的名字,也定义需要这个控制器处理的</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">URL</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 宋体;">样式</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US"> --&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">    </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">bean </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"/hello.do"</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">       </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">class</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"com.wepull.test.HelloController"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">    </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">bean</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">beans</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">上面可能有人奇怪,为什么不用</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">id</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">属性,而设置</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">name</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">属性。这里是因为</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">中含有</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">XML id</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">属性非法字符——特别是斜杠(</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">/</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">)</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(4)</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">配置一个视图解析器将控制器与</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">JSP</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">结合起来。</span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">将解析器的配置片段加到上面的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">test-servlet.xml</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">中。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">bean </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">id</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"viewResolver"</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">    </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">class</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"org.springframework.web.servlet.view.InternalResourceViewResolver"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">       </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">property </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"prefix" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">value</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"/WEB-INF/jsp/" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">/&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">       </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">property </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">name</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"suffix" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">value</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">".jsp" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">/&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">bean</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">InternalResourceViewResolver</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 宋体;">在</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">ModelAndView</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">返回的视图名前加上</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">prefix</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">属性配置的前缀</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">,</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">再在最后加上</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">suffix</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">属性配置的后缀。由于</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">HelloController</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">返回的</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">ModelAndView</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">中视图名为</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">welcome,</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 宋体;">所以</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">InternalResourceViewResolver</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 宋体;">将在</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">/WEB-INF/jsp/welcome.jsp</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 宋体;">处查找视图。</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(5)</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">编写呈现给用户的</span><span style="margin: 0px; padding: 0px; color: #99cc00;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">jsp</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; color: #99cc00; font-family: 宋体;">文件。</span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-size: small; font-family: 'Times New Roman';"> </span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">/WEB-INF/jsp/welcome.jsp</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #bf5f3f; font-family: 'Courier New';" lang="EN-US">&lt;%@ </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">page </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">contentType</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"text/html; charset=UTF-8"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #bf5f3f; font-family: 'Courier New';" lang="EN-US">%&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #bf5f3f; font-family: 'Courier New';" lang="EN-US">&lt;%@ </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">page </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">isELIgnored</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"false" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #bf5f3f; font-family: 'Courier New';" lang="EN-US">%&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #bf5f3f; font-family: 'Courier New';" lang="EN-US">&lt;%@ </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">taglib </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">prefix</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"c" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">uri</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"http://java.sun.com/jsp/jstl/core"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #bf5f3f; font-family: 'Courier New';" lang="EN-US">%&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;!</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">DOCTYPE </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: navy; font-family: 'Courier New';" lang="EN-US">html </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: gray; font-family: 'Courier New';" lang="EN-US">PUBLIC </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: navy; font-family: 'Courier New';" lang="EN-US">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f5f; font-family: 'Courier New';" lang="EN-US">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">html </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">xmlns</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"http://www.w3.org/1999/xhtml"</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">head</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">meta </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">http-equiv</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"Content-Type" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #7f007f; font-family: 'Courier New';" lang="EN-US">content</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">=</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #2a00ff; font-family: 'Courier New';" lang="EN-US">"text/html; charset=utf-8" </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">/&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">title</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">Hello World!</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">title</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">head</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">body</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">h2</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"><span style="margin: 0px; padding: 0px;">   </span>${hello}</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US">  </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">h2</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;" align="left"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: black; font-family: 'Courier New';" lang="EN-US"> </span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">body</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&lt;/</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: #3f7f7f; font-family: 'Courier New';" lang="EN-US">html</span><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US">&gt;</span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: 10pt; color: teal; font-family: 'Courier New';" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">完成后启动服务器,在浏览器地址栏上输入</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">http://locahost:8080/projectName/hello.do<span style="margin: 0px; padding: 0px;">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">就可以访问了。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">对照一下,我们发现</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">跟</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Struts</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">大同小异。只是有两处映射,</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">做的相对灵活。哪两处呢?</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"><span style="margin: 0px; padding: 0px; font-size: small;">(1) <strong style="margin: 0px; padding: 0px;">url</strong></span></span></span><span style="margin: 0px; padding: 0px; font-size: small;"><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">和动作</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">后端控制器</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">)</span></span></strong><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">的映射。</span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">springMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">里有个映射处理器</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(HandlerMapping)</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的概念。它实际上是一个处理器映射</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Bean,</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">用来将一个控制器指定到一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">上。</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Spring</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">提供了三种有用的</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">HandlerMapping</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的实现:</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> <span style="margin: 0px; padding: 0px;" lang="EN-US">BeanNameUrlHandlerMapping</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">根据控制器的名字将控制器映射到</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> <span style="margin: 0px; padding: 0px;" lang="EN-US">SimpleUrlHandlerMapping</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">用上下文配置文件中定义的属性集合将控制器映射到</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> <span style="margin: 0px; padding: 0px;" lang="EN-US">CommonsPathMapHandlerMapping</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">使用控制器代码中的元数据将控制器映射到</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">URL<span style="margin: 0px; padding: 0px;">  </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(2) </span></span><strong style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">逻辑视图名和视图对象的映射。</span></strong></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">springMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">里还有个视图解析器</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(ViewResolver)</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的概念。它决定了</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ModelAndView</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">对象的逻辑视图名如何解析成一个用于将结果渲染给用户的视图</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Bean..Spring</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">有四种</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ViewResolver</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">实现:</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> <span style="margin: 0px; padding: 0px;" lang="EN-US">InternalResourceViewResolver</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">将逻辑视图名解析成一个用模板文件</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">(</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">如</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">JSP</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">和</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Velocity</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">模板</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">)</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">渲染的视图对象</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> <span style="margin: 0px; padding: 0px;" lang="EN-US">BeanNameViewResolver</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">将逻辑视图名解析成一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">应用上下文中的视图</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Bean</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> <span style="margin: 0px; padding: 0px;" lang="EN-US">ResourceBundleViewResolver</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">将逻辑视图名解析成一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">ResourceBundler</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">中的视图对象</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px; font-family: 宋体;">——</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';"> XmlViewResolver</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">从一个</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">XML</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">文件中解析视图</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Bean,</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">这个文件是从</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">DispatcherServlet</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">应用上下文中分离出来的。</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; font-family: Arial; line-height: 26px; white-space: normal;"><span style="margin: 0px; padding: 0px; font-size: small;"><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">       </span></span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">好啦,今天就算是</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">的一个入门。建议大家将</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">Struts</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">和</span><span style="margin: 0px; padding: 0px;" lang="EN-US"><span style="margin: 0px; padding: 0px; font-family: 'Times New Roman';">SpringMVC</span></span><span style="margin: 0px; padding: 0px; font-family: 宋体;">对照着学习,那样效果会更好。与人分享,集思广益。希望大家都能够学习快乐,工作顺心。下次再见。</span></span></p>
<p> </p>
</div>

你可能感兴趣的:(springMVC)