当前位置:网站首页>Urlparrern configuration
Urlparrern configuration
2022-07-22 10:35:00 【Hua Weiyun】
urlParrern To configure
Previously, we used annotations to configure this access path , Only one access path is set . In fact, you can also configure multiple access paths . Just like this. .
@WebServlet(urlPatterns = {"/demo7","/demo07"})
In fact, our configuration is a path matching rule or an item matching access rule .
Next we introduce several matching rules
1: Exactly match
What we wrote in the notes , In the future, we need to access the project through this complete path .
eg:
@WebServlet("/jgdabc/666")
2: Directory matching
eg:
/@WebServlet(urlPatterns = "/user/*") Directory matching
When we visit in the future, we need to input user, Then you can follow any path .
3: Extension matching
@WebServlet("*.do")
Any path can be added to the front when visiting in the future , But you need to add do Extension .
4: Any match
//@WebServlet("/")//@WebServlet("/*")
Arbitrary matching is not recommended
- When... In our project Servlet Configured with “/”, Will overwrite tomcat Medium DefaultServlet, When other url-pattern When they don't match, they will take this Servlet
- When our project is configured with "/*", Means matching any access path
- DefaultServlet Is used to handle static resources , If the "/" Will overwrite the default , It will cause the user-defined instead of the default when requesting static resources Servlet class , As a result, static resources cannot be accessed
The test case
package jgd;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;@WebServlet("/jgdabc/666")// Multiple access paths can be configured , This is an exact match //@WebServlet(urlPatterns = {"/demo7","/demo07"})//@WebServlet(urlPatterns = "/user/*") Directory matching // When both exact matching and directory matching are satisfied , Precise matching has higher priority //@WebServlet("*.do") Extension matching // Any match // /* Has a higher priority than ///@WebServlet("/")//@WebServlet("/*")public class ServletDemo7 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("demo7get..."); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {// super.doPost(req, resp); }}
边栏推荐
- urlParrern配置
- 什么是FastAPI异步框架?(全面了解)
- Servlet篇章一
- Execution failed for task ‘:app:kaptDevDebugKotlin‘.
- Immunefi of hacker bounty hunter platform
- 什么是FastAPI异步框架?(全面了解)
- Recommendation of top 10 mainstream pressure / load / performance testing tools
- 2022 third party pagoda panel btcloud PHP source code
- 【GNN】Graph Lifelong Learning: A Survey
- HCIP(9)
猜你喜欢
Embedded bus and communication
Save web pages as PDF artifacts (customizable) - print edit we
洗衣店小程序源码-增加对接第三方跑腿
Enter the password to browse the PHP source code of the web page
从零复现PyTorch版(3)
Live broadcast preview | new design ideas and production methods brought by NFT, aigc/ugc tools and metauniverse products
智能手机天线调谐
Memorize these interview questions, and you will be half successful in any technical aspect
1307_嵌入式设计中的晶振测试小结
Energy principle and variational method note 10: virtual displacement principle
随机推荐
el-table-column嵌套el-table-column ,多级表头横向滚动的bug
Eolink ——通过文档驱动,快速开发接口
1307_ Summary of crystal oscillator test in embedded design
Set elastic box justify content: space between does not take effect
cron表达式详解
Unity Scrollview scroll to the specified position
Recommendation of top 10 mainstream pressure / load / performance testing tools
Use cpolar to build a business website (3)
Understanding and operation of pointer
urlParrern配置
day02-2
HCIP(10)
Finalizer of JVM
day02-2
公司新来一个同事,把 Typora 玩得炉火纯青!太强悍了
研发中台拆分过程的一些心得总结
Summary of some experiences in the process of R & D platform splitting
11-GuliMall 后台管理中商品系统的分类维护
Microgrid scheduling based on Kalman filter (matlab code implementation)
C#实现给PDF文档设置过期时间