- 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
- C程序設計簡明教程(第二版)
- 程序設計與實踐(VB.NET)
- 少年輕松趣編程:用Scratch創作自己的小游戲
- Scratch真好玩:教小孩學編程
- Web程序設計(第二版)
- 正則表達式經典實例(第2版)
- FPGA Verilog開發實戰指南:基于Intel Cyclone IV(進階篇)
- Machine Learning for Developers
- Practical Predictive Analytics
- Get Your Hands Dirty on Clean Architecture
- Python物理建模初學者指南(第2版)
- MySQL數據庫應用實戰教程(慕課版)
- Python數據預處理技術與實踐
- Enterprise Application Architecture with .NET Core
- Mastering React Test:Driven Development