Spring in the View and the use of ViewResolver

2009-10-29  来源:本站原创  分类:Java  人气:414 

Spring open source code, we can see a lot of org.springframework.web.servlet.view package under the View and ViewResolver classes; View class provide us with some of the default to be extended View, such as org.springframework.web. servlet.view.document.AbstractExcelView provides a default Excel
Format View, org.springframework.web.servlet.view.document.AbstractPdfView provides a default pdf format View; through resource allocation and ViewResolver document the use of, we can show to the user each have our own style of View.
org.springframework.web.servlet.view package under several ViewResolver to achieve, which default to InternalResourceViewResolver. For example configuration file is as follows:
<bean>
<property name="viewClass"> <value> org.springframework.web.servlet.view.JstlView </ value> </ property>
<property name="prefix"> <value> / WEB-INF/jsp / </ value> </ property>
<property name="suffix"> <value>. jsp </ value> </ property>
</ bean>
The above configuration that the Controller will be based on the ModelAndView returned, combined with directory prefix / WEB-INF/jsp /,
After the file name plus suffix. Jsp, thus waiting for the next pages, such as / WEB-INF/jsp/showCats.jsp
Another ViewResolver is ResourceBundleViewResolver, such as configuration file is as follows:
<bean>
<property name="basename"> <value> views-countries </ value> </ property>
<property name="defaultParentView"> <value> modelView </ value> </ property>
</ bean>
basename of the classes directory from the configuration that the views-countries.properties file, access to resources, so that we can easily achieve the internationalization and localization;
defaultParentView that all of the view are inherited from the modelView in it, and is very similar to the configuration of log4j.
Other ViewResolver with the above analysis of the two kinds of similar.

相关文章
  • Spring in the View and the use of ViewResolver 2009-10-29

    Spring open source code, we can see a lot of org.springframework.web.servlet.view package under the View and ViewResolver classes; View class provide us with some of the default to be extended View, such as org.springframework.web. servlet.view.docum

  • Spring MVC 解读--View,ViewResolver 2014-04-12

    上一篇文章(1)(2)分析了Spring是如何调用和执行控制器方法,以及处理返回结果的,现在我们就分析下Spring如何解析返回的结果生成响应的视图. 一.概念理解 View ---View接口表示一个响应给用户的视图,例如jsp文件,pdf文件,html文件等,它的定义如下 public interface View { //HttpServletRequest中的属性名,其值为响应状态码 String RESPONSE_STATUS_ATTRIBUTE = View.class.getNam

  • How to view existing projects and the spring version of struts and hibernate 2010-10-31

    View the current project version of struts and hibernate and spring 1. View struts.jar \ META-INF \ MANIFEST.MF And then view the Implementation-Version Look behind the numbers .. Manifest-Version: 1.0 Specification-Title: Struts Framework Class-Path

  • Use Spring 3 to create RESTful Web Services 2011-05-27

    Use Spring 3 to create RESTful Web Services Yi Ming Huang , Software Engineer, IBM Dong Fei Wu , Software Engineer, IBM Introduction: In the Java ™ , you can use the following method to create RESTful Web Service: Use JSR 311 (311) and its reference

  • spring MVC工作机制与设计模式-读后小结(三) 2013-05-16

    Control的调用(续) 接着对于(二)的补充:主要是小结下Control的处理逻辑的关键操作: 对于control的处理关键就是:DispatcherServlet的handlerMappings集合中根据请求的URL匹配每一个handlerMapping对象中的某个handler,匹配成功之后将会返回这个handler的处理连接handlerExecutionChain对象.而这个handlerExecutionChain对象中将会包含用户自定义的多个handlerInterceptor对

  • dwr configuration file dwr.xml 2009-06-26

    I dwr Chinese document on a collation do dwr.xml purely jobs they take, there are useful do not forget to top friend you, leave a contact with the exchange of learning! Welcome to my site to exchange technical www.ithuzhu.com dwr.xml is the DWR confi

  • (Turn) EL Expression 2008-10-09

    1, EL Introduction 1. Grammatical structure $ (expression) 2. [] And. Operator EL offers. And [] two kinds of operators to access the data. When you want to access the property name contains some special characters, such as. Or? Such as letters or nu

  • (Transfer) EL expression 2010-03-08

    1, EL Introduction 1. Grammatical structure of $ (expression) 2. [] And. Operator EL provide. And [] of two operators to access the data. When you want to access the property name contains special characters, such as. Or? Such as letters or numbers a

  • dwr configuration file dwr.xml Explained (change) 2010-04-12

    dwr.xml is the DWR configuration file. By default, it should put it in WEB-INF directory (web.xml directory) to create dwr.xml file dwr.xml file is structured as follows: <dwr> <! - Init is only needed if you are extending DWR -> <init>

  • spring3 MVC jquery ajax under the combination of simple to use - Super Simple 2010-04-13

    Today need to write a simple application: user registration, check the user name is available. Seemingly on the next before struts2 ajax support is good (actually irritated), and there are many online tutorials. But this is replaced springmvc, and it

  • eclipse debug programs 2010-07-08

    When using the Eclipse development tool, only know some simple debug commands in the debug process for the operation of a filter property values, etc. do not know what to do. In fact, Eclipse, and integrates such functions, simple operation as follow

  • Class class loader on the issue of memory leaks 2010-07-29

    Since: http://blog.csdn.net/runanli/archive/2008/09/24/2972361.aspx Wave background and technical personnel for the Guangdong Tobacco Tobacco December 10 memory overflow events of a wide range of technology and get some constructive suggestions and c

  • Class loader - the memory leak problem of a 2010-07-29

    About websphere console to restart the application, rather than restart the websphere, this time a static class can not be recovered, resulting in some classes can not be destroyed, occupied by the memory, but this memory can not be reused, can be sa

  • DWR-depth understanding of 2010-09-27

    Here are some terms must be understood - parameter will be converted, remote Bean will be created. So if you have a name A, bean, it has a method called A.blah (B) then you need an A, B, creator and a converter. 1: <allow> allow the definition of th

  • DWR Chinese documents 2010-09-29

    dwr.xml paper is structured as follows: Here are some terms must be understood that the term - the parameter will be converted, the remote Bean will be created. So if you have a name A, bean, it has a method called A.blah (B) then you need an A, B, c

  • Summary information on J2EE clustering concept 2010-12-03

    J2EE clustering concept In addition to load balancing personal feeling is frequently used in the production, failover, I have not come across such a project. Failover too expensive, considering the problems are very complex, the feeling is not very h

  • springMVC_数据的处理过程 2011-09-15

    1.DispatcherServlet:作为前端控制器,负责分发客户的请求到 Controller 其在web.xml中的配置如下: < servlet > < servlet-name >dispatcherServlert </ servlet-name > < servlet-class > org.springframework.web.servlet.DispatcherServlet </ servlet-class > < i

  • beelt使用说明 2014-02-19

    <!-- [if gte mso 9]><xml><w:WordDocument><w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel><w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery><w:DisplayVerticalDrawingGridEvery

  • SpringMVC+Hibernate +MySql+ EasyUI实现CRUD(一) 2014-11-15

    http://pan.baidu.com/s/1mg3MJTQ 最新项目下载地址 访问地址 1.基于easyui的 增 删 改 查 2.基于poi的导出excel 3.基于 SpringMVC HandlerInterceptor验证 项目结构图 源代码和jar包等下会上传是百度网盘 http://yun.baidu.com/pcloud/album/info?query_uk=3724757956&album_id=3094796070610213829 . 一:web.xml代码 <?x

  • Spring MVC: used InternalResourceViewResolver view resolver 2010-03-29

    Reference: Sping 2.0.8 \ docs \ MVC-step-by-step To achieve its objectives Write a ShirdrnController, implements org.springframework.web.servlet.mvc.Controller interface; Using the JSP file as a view of the controller to return the Model rendered, JS