Spring MVC framework[1] Configuration
来源:互联网 发布:java 空格 显示问号 编辑:程序博客网 时间:2024/06/05 16:53
All contents are referenced from Spring In Action
servlet-context.xml specified in web.xml is used by DispatcherServlet to defines its request-processing context.
web.xml:
<servlet><servlet-name>appServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/spring/appServlet/<strong><span style="color:#ff0000;">servlet-context.xml</span></strong></param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>appServlet</servlet-name><url-pattern>/</url-pattern></servlet-mapping>
in servlet-context.xml , Spring’s mvc namespace includes a new <mvc:resources> element that handles requests for static content.
servlet-context.xml:
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory--> <resources mapping="/resources/**" location="/resources/" /> <!-- ** is Ant-style wildcard -->As configured here, any requests whose paths begin with /resources will be automatically served from the /resources folder at the root of the application
DispatcherServlet consults one or more handler mappings in order to know which controller to dispatch a request to.
one of the mappings, DefaultAnnotationHandlerMapping maps requests to controller methods that are annotated with @RequestMapping.
we’ll also use annotations to bind request parameters to handler method parameters, perform validation, and perform message conversion.
To turn on annotation-driven features of Spring MVC, put <mvc:annotation-driven> in servlet-context.xml.
servlet-context.xml:
<!-- Enables the Spring MVC @Controller programming model --><annotation-driven />
<mvc:annotation-driven> registers several features, including JSR-303 validation support, message conversion, and support for field formatting.
- Spring MVC framework[1] Configuration
- Spring @MVC configuration without XML
- Spring Framework MVC
- Spring MVC Framework Tutorial
- Spring - MVC Framework 教程
- Spring MVC framework总体分析
- Spring MVC framework 执行过程
- Spring MVC framework深入分析
- Spring Framework MVC 学习感想!
- Spring MVC framework总体分析
- Spring MVC framework 执行过程
- Spring MVC framework深入分析
- SPRING 3 MVC FRAMEWORK INTRODUCTION
- Spring MVC framework[2] Controller
- Spring MVC Test Framework简译
- Spring MVC 学习笔记 二 spring mvc Schema-based configuration
- Spring 3 MVC – Introduction to Spring 3 MVC Framework
- Spring 3 MVC – Introduction to Spring 3 MVC Framework
- ASP.NET js控制TextBox只能输入数字和小数点
- 怎样写好求职简历?
- 第四周项目4:指向学生类的指针
- 记一次tcmalloc分配内存引起的coredump
- Validate Binary Search Tree
- Spring MVC framework[1] Configuration
- 给百度自行车提的意见
- 1.Android快速入门
- svn+apache
- 解决"vs2002/vs2003无法启动调试"问题
- thead,tbody,tfoot标签的用法
- 【Android开发】Android中LayoutInflater的使用
- C compile error:fatal error C1083: 无法打开包括文件.h
- lua table的长度问题