`
Grassflying2
  • 浏览: 6593 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

springMVC入门

 
阅读更多
<div class="iteye-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>
分享到:
评论

相关推荐

    maven + springmvc 入门实例

    **二、SpringMVC入门** 1. **创建SpringMVC项目**: 使用Maven创建一个新的Maven项目,在`pom.xml`中添加SpringMVC相关的依赖,如`spring-webmvc`、`spring-context`、`jstl`等。 2. **配置SpringMVC**: 创建`web....

    SpringMVC入门jar包

    在这个"SpringMVC入门jar包"中,包含了一系列必要的库文件,它们是构建基于SpringMVC的应用的基础。 首先,SpringMVC的核心组件包括DispatcherServlet,它是SpringMVC的前端控制器,负责接收HTTP请求,并将其分发到...

    springmvc入门程序(下载后你不会后悔的)

    #### 三、SpringMVC入门程序 ##### 1. 目标 入门程序的主要目的是帮助开发者理解SpringMVC的核心组件及其工作流程,特别是前端控制器、处理器映射器、处理器适配器和视图解析器。 ##### 2. 实现方式 - **非注解...

    SpringMVC入门demo

    创建SpringMVC入门项目** 1. **项目结构**:通常包括`src/main/java`(源代码)、`src/main/resources`(配置文件)和`src/main/webapp`(Web应用目录)。 2. **配置文件**: - `web.xml`:配置`...

    SpringMvc入门

    本知识点将从SpringMVC的架构原理、MVC设计模式、Web开发的请求响应模型和Web端开发发展历程等方面详细阐述。 首先,Spring MVC是一个实现了Web MVC架构模式的框架。MVC模式将应用程序分为三个核心组件:模型(Model...

    springmvc入门程序

    在这个"springmvc入门程序"中,我们将探讨如何使用 Spring MVC 和 MyBatis 集成来构建一个简单的商品管理应用。 首先,Spring MVC 提供了DispatcherServlet,作为应用程序的前端控制器,它接收所有的 HTTP 请求,并...

    springMvc入门级教材

    刚接触springMvc时参考的教材,理论和操作兼顾,写的很好,对于springMvc的初学者帮助很大

    SpringMVC入门最简洁工程

    这个"SpringMVC入门最简洁工程"是一个针对初学者精心设计的项目,它包含了必要的配置文件和最少的依赖包,以便快速理解和上手SpringMVC。 **1. MVC架构** 在Web开发中,MVC架构是一种常用的分层设计模式。Model...

    SpringMVC 入门小程序

    **SpringMVC 入门小程序详解** SpringMVC是Spring框架的一个重要模块,它是一个用于构建Web应用程序的轻量级、模型-视图-控制器(MVC)框架。本入门程序旨在帮助初学者理解并掌握SpringMVC的基本概念和工作流程,...

    springmvc入门参数绑定ssm整合

    SpringMVC入门参数绑定SSM整合 SpringMVC是一种基于MVC模式的Web应用程序框架,它是Spring框架的一个模块,用于开发Web项目。下面是SpringMVC入门参数绑定SSM整合的知识点总结: 一、SpringMVC概述 SpringMVC是...

    SpringMVC学习(一)——SpringMVC入门小程序

    在“SpringMVC学习(一)——SpringMVC入门小程序”中,我们首先会接触到SpringMVC的基本概念。这通常包括以下几个核心组件: 1. **DispatcherServlet**:这是SpringMVC的前端控制器,负责接收HTTP请求,并根据配置...

    尚硅谷SpringMVC入门到精通

    尚硅谷SpringMVC入门到精通,涵盖数据绑定、异常处理以及与Spring的基本整合

    springMvc入门级项目

    在本入门级项目中,我们将深入理解 Spring MVC 的基本概念、配置以及如何创建一个简单的应用程序。 首先,让我们了解 Spring MVC 的核心组件: 1. **DispatcherServlet**:这是 Spring MVC 的前端控制器,负责接收...

    springmvc入门helloworld

    在"springmvc入门helloworld"这个主题中,我们将探讨如何从零开始搭建一个简单的Spring MVC项目,展示其基本工作流程和关键组件。以下是详细的知识点讲解: 1. **Spring MVC 概述** - Spring MVC 是Spring框架的一...

    SpringMvc入门工程源码

    SpringMvc入门工程源码是一个适合初学者了解和学习Spring MVC框架的项目。Spring MVC是Spring框架的一个模块,专门用于构建Web应用程序。它提供了一个模型-视图-控制器(MVC)架构,帮助开发者将业务逻辑、数据处理...

    SpringMVC入门->网站的初级框架

    在“SpringMVC入门-&gt;网站的初级框架”中,我们将探讨如何使用SpringMVC构建一个简单的网站登录功能。 首先,我们需要理解SpringMVC的工作流程。当用户通过浏览器发送一个HTTP请求到`localhost:8080/ws/web/login`...

    一个简单的springMVC入门项目

    这个名为"一个简单的springMVC入门项目"的压缩包文件可能是为了帮助初学者了解和掌握SpringMVC的基本概念和操作流程。让我们深入探讨一下SpringMVC的核心组件和关键功能。 1. **DispatcherServlet**:作为SpringMVC...

    SpringMVC专栏 002 SpringMVC入门项目搭建

    SpringMVC专栏 002 SpringMVC入门项目搭建

    springmvc入门小项目:CRUD

    在这个"springmvc 入门小项目:CRUD"中,我们将探讨如何使用 SpringMVC 实现基本的数据库操作,即创建(Create)、读取(Read)、更新(Update)和删除(Delete)数据。 1. **SpringMVC 框架基础** - **...

    SpringMVC 入门 框架搭建demo,

    **SpringMVC 入门与框架搭建** SpringMVC 是 Spring 框架的一个模块,主要负责处理 Web 应用程序中的请求和响应。它是一个轻量级的、基于模型-视图-控制器(MVC)设计模式的 Web 开发框架,提供了强大的数据绑定、...

Global site tag (gtag.js) - Google Analytics