web.xml中url-pattern中⼀和⼀*的区别

2025-03-10 03:50:58
推荐回答(1个)
回答1:

在写springMVC小例子的时候遇到了拦截的问题,在url-pattern中参数的两种方式
一、

[html] view plain copy

springMVC
/


二、
[html] view plain copy

encodingFilter
/*
前一种< url-pattern > / 不会拦截*.jsp,也就不会进入spring的DispatcherServlet类。后一种< url-pattern > /* 会拦截,就是说所有的这个项目的请求都会被捕捉,过滤,同是为避免静态资源被拦截需要在spring.xml文件中配置