- Java EE 8 Design Patterns and Best Practices
- Rhuan Rocha Jo?o Purifica??o
- 307字
- 2021-07-23 16:54:53
Deciding filter mapping
Defining the mapping method is crucial to implementing the intercepting filter pattern. This is because a bad method for mapping can impact the project directly and cause rework. We have two filter mapping types—UrlPattern and servlet name.
The use of UrlPatterns is indicated when we want to filter the HTTP Requests to non-specific resources or files, but we also want to filter various unknown resources. Here are some examples of this:
- *.jsp: This filters all requests to JSP pages. If one JSP page is added to the server, then the filter will filter the new JSP page without making any modifications.
- /*: This filters all requests to all resources or files on the server. If one resource or file is added to the server, then the filter will filter this new resource or file without performing any modifications.
- /user/*: This filters all requests to all resources or files on the server that have a URI beginning with /user. If one resource or file that is accessed by a URI beginning with /user is added on servlet, then the filter will filter this new resource or file without performing any modifications.
The servlet name used to map the filter indicates when you want to filter a specific servlet, independent of its urlPattern. This way of mapping allows us to modify one urlPattern of the mapped servlet without performing any modifications on the filter. Here are some examples:
- {servlet1}: This only maps the servlet named as servlet1. If the urlPatterns of servlet1 are modified, then the filter doesn't need to be modified.
- {servlet1,servlet2}: This maps two servlets named servlet1 and servlet2. Its behavior is similar to the previous example shown, in which only one servlet was mapped.
推薦閱讀
- 電腦組裝與系統(tǒng)安裝
- Windows Server 2019 Cookbook
- 樂學(xué)Windows操作系統(tǒng)
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程(Windows 7+Office 2013)
- 蘋果電腦玩全攻略 OS X 10.8 Mountain Lion
- Hands-On DevOps with Vagrant
- Implementing Azure DevOps Solutions
- 深入Linux內(nèi)核架構(gòu)與底層原理(第2版)
- Dreamweaver CS5.5 Mobile and Web Development with HTML5,CSS3,and jQuery
- AutoCAD 2014中文版從入門到精通
- Linux內(nèi)核設(shè)計(jì)的藝術(shù):圖解Linux操作系統(tǒng)架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- Mastering Windows 8 C++ App Development
- Raspberry Pi入門指南
- Gradle Effective Implementations Guide(Second Edition)
- Linux應(yīng)用大全 服務(wù)器架設(shè)