application.xml与工程配置:

index.jsp在webapp下,可以直接请求。
配置还有:<mvc:annotation-driven></mvc:annotation-driven>
web.xml配置DispatcherServlet拦截/*时,index.jsp请求被拦截
配置mvc:resource,此时路径是/WEB-INF/Page/index.jsp,显示404
去掉mvc:resource配置,DispatcherServlet拦截/*,JSP被通配符的Spring拦截
这时路径:localhost:8080/index.jsp,真实路径:/index.jsp 路径没有被映射,可对index.jsp请求
经过Spring拦截,但请求资源存在,显示效果,做静态资源下发了:

web.xml配置DispatcherServlet拦截/,jsp没被Spring拦截,发起访问,进入index.jsp,页面正常显示。
本文深入探讨了Spring MVC框架中application.xml与web.xml的配置细节,包括DispatcherServlet的拦截配置、mvc:annotation-driven与mvc:resource的使用场景,以及不同配置下静态资源如index.jsp的请求处理方式。
2252

被折叠的 条评论
为什么被折叠?



