1. web.xml中url-pattern配置
url-pattern为/
使用SpringMVC的框架时,需要在web.xml配置前端控制器DispatcherServlet,配置为:
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
1
springmvc
/
url-pattern为/*
我们需要使用过滤器时,需要在web.xml中进行注册。以处理中文乱码的过滤器CharacterEncodingFilter为例,配置为:
CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceRequestEncoding
true
forceResponseEncoding
true
CharacterEncodingFilter
/*
url-pattern为*.do
使用Struts框架时,需要在web.xml中配置控制中心ActionServlet的拦截规则:
action
org.apache.struts.action.ActionServlet
config
/WEB-INF/struts-config.xml
debug
3
application