Spring MVC View Parser
1. Request direct access to the page without controller
<!---<path= "/success" view-name = "Success" /> <!-- -<mvc:annotation-driven></MVC: Annotation-driven>
2. Accessing the page static resources
<!--configure access to static resources start -<mvc:resourcesMapping= "/js/**" Location= "/resources/js/" /><mvc:resourcesMapping= "/css/**" Location= "/resources/css/" /><mvc:resourcesMapping= "/images/**" Location= "/resources/images/" /><mvc:resourcesMapping= "/upload/**" Location= "/upload/" /><mvc:resourcesMapping= "/**/*.html" Location="/"/><!--<mvc:default-servlet-handler/> -<Mvc:annotation-driven></Mvc:annotation-driven><!--configure access to static resources end -
3. Custom views
/*** 1. Customize the view to implement the view interface, override the method for the, and then add the custom view to the spring IOC container in * 2.Controller to return the custom view in the Spring container name * 3. The remaining operations are implemented by render and getContentType **/@Component Public classSelfviewImplementsview{ PublicString getContentType () {return"Text/html"; } Public voidRender (Map<string,?>model, HttpServletRequest request, httpservletresponse response)throwsException {response.getwriter (). Print ("Hello View, Time:" +NewDate ()); }}
@RequestMapping ("TestView") public String TestView () { System.out.println (" Hello This is TestView "); return "Selfview"; }
<!--Configure the View resolver: How to resolve the handler method return value to the actual physical view - <Beanclass= "Org.springframework.web.servlet.view.InternalResourceViewResolver"> < Propertyname= "prefix"value= "/web-inf/views/"></ Property> < Propertyname= "suffix"value= ". jsp"></ Property> </Bean> <!--Configure the View resolver for the Beanname order to give the view priority a random value for the row is lower than the Internalresourceviewresolver priority level - <Beanclass= "Org.springframework.web.servlet.view.BeanNameViewResolver"> < Propertyname= "Order"value= "+"></ Property> </Bean>
Spring MVC Fundamentals Article 6