- Spring MVC:Beginner's Guide(Second Edition)
- Amuthan Ganeshan
- 163字
- 2021-07-14 10:49:47
Servlet mapping versus request mapping
The servlet mapping specifies which web container of the Java servlet should be invoked for a given URL. It maps the URL patterns to servlets. When there is a request from a client, the servlet container decides which servlet it should forward the request to based on the servlet mapping. In our case, we mapped all incoming requests to DispatcherServlet
.
In contrast, request mapping guides the DispatcherServlet
which controller method it needs to invoke as a response to the request based on the request path. In our case, we mapped the /welcome
request path to the welcome
method of the HomeController
class.
Pop quiz - servlet mapping
Considering the following servlet mapping, identify the possible matching URLs:
@Override protected String[] getServletMappings() { return new String[] { "*.do"}; }
http://localhost:8080/webstore/welcome
http://localhost:8080/webstore/do/welcome
http://localhost:8080/webstore/welcome.do
http://localhost:8080/webstore/welcome/do
Considering the following servlet mapping, identify the possible matching URLs:
@Override protected String[] getServletMappings() { return new String[] { "/"}; }
http://localhost:8080/webstore/welcome
http://localhost:8080/webstore/products
http://localhost:8080/webstore/products/computers
- All the above
- Instant Node Package Manager
- VMware View Security Essentials
- WildFly:New Features
- Dynamics 365 Application Development
- Java EE 7 Development with NetBeans 8
- FFmpeg入門詳解:音視頻原理及應用
- Building an RPG with Unity 2018
- Getting Started with Greenplum for Big Data Analytics
- Unity UI Cookbook
- Getting Started with React Native
- Python3.5從零開始學
- MINECRAFT編程:使用Python語言玩轉我的世界
- Everyday Data Structures
- 3ds Max 2018從入門到精通
- HTML5 WebSocket權威指南