Spring MVC 访问静态资源
当我们不通过控制器,想直接访问网站上的静态资源时,由于DispatcherServlet的url-patten的通配符的限制,导致系统会认为你访问的是个url映射,这时需要配置一个东西就可以解决问题了。
在SpringMVC的配置文件中 <mvc:resources location="/**" mapping="/res/**"/> 搞定
http://localhost:8080/glq/res/1.jhtml
尽管路径和url-patten的路径相符,但是由于找不到url mapping,spring会自动去找与它同名的静态文件,找到返回结果,再找不到的话,报404.
Spring MVC 访问静态资源的更多相关文章
- Spring MVC访问静态资源
http://www.cnblogs.com/yank/p/4477204.html SpringMVC访问静态资源 在SpringMVC中常用的就是Controller与View.但是我们常常会需要 ...
- spring mvc 访问静态资源404
访问比如css js出现404提示 在spring的配置文件中加上如下代码即可 <!-- 静态资源404 --> <mvc:resources location="/res ...
- 【Spring学习笔记-MVC-14】Spring MVC对静态资源的访问
作者:ssslinppp 参考链接: http://www.cnblogs.com/luxh/archive/2013/03/14/2959207.html http://www.cnb ...
- Spring MVC 处理静态资源文件
摘要: 三个方案: 1.方案一:激活Tomcat的defaultServlet来处理静态文件 2.方案二: 在spring3.0.4以后版本提供了mvc:resources (需要配置annotati ...
- Spring MVC配置静态资源和资源包
Spring MVC配置静态资源和资源包 本例映射:css目录: pom.xml <properties> <spring.version>4.3.5.RELEASE</ ...
- spring mvc对静态资源的访问
如果我们的项目使用的是springmvc,在web.xml中会有一段这的配置. <servlet> <servlet-name>springMvc</servlet-na ...
- spring mvc添加静态资源访问时@Controller无效的解决
web.xml中的url-pattern设置为/,添加mvc:resources访问静态资源时,@Controller无效的问题 web.xml: <servlet> <servle ...
- spring mvc处理静态资源
servlet的url映射定义为'/'表示映射全部路径 struts的过滤器是*.action,在spring mvc中设置成*.action或者*.do......也是可以的,但是spring mv ...
- Spring MVC 读取静态资源时404错误
背景:web.xml配置时拦截策略是拦截所有请求: <servlet> <servlet-name>springmvc</servlet-name> <ser ...
随机推荐
- Concurrency in csharp (Asynchronous, Parallel, and Multithreaded Programming)
http://stephencleary.com/projects/ /// <summary> /// /// </summary> public partial class ...
- java对email邮箱的真实、有效性验证
三种验证邮箱有效性的方式: 方式1: public static boolean checkEmail(String email) { if (!email.matches("[\\ ...
- 最短路径——Floyd-Warshall算法
Floyd-Warshall算法,简称Floyd算法,用于求解任意两点间的最短距离,时间复杂度为O(n^3). 我们平时所见的Floyd算法的一般形式如下: void Floyd() { int i, ...
- The habits of highly successful people
1.Morning Routine (早上列行公事) Probably the most common habit ultra-successful people have is they can t ...
- JavaScript的几种Math函数,random(),ceil(),round(),floor()
1.Math.random():返回 0 ~ 1 之间的随机数.2.Math.ceil():返回值:返回大于或等于x,并且与之最接近的整数(如果x是正数,则把小数"入":如果x是负 ...
- 关于float和margin
1.同级存在浮动,如mid的前面left浮动(mid不浮动),margin则相对于父元素,mid的margin-left不是相对于left,而是相对于con(可以想象,如果left不浮动,则mid和l ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q141-Q143)
Question 141 You are planning an upgrade to a SharePoint 2010 application. You have the following r ...
- Android—android与js交互以及相互传参
Android中可以通过WebView来实现与js的交互,让用户可以在android客户端看到js写的页面,接下来为大家介绍的就是怎样实现此功能: 首先android项目目录下有“assets”文件夹 ...
- iOS导航栏标题颜色
按钮的颜色 [self.navigationBar setTintColor:[UIColor whiteColor]]; 标题颜色.字体 [self.navigationBar setTitleTe ...
- 深度技术GHOST WIN7系统32.64位j极速安装版 V2016年
系统来自系统妈:http://www.xitongma.com 深度技术GHOST win7系统64位j极速安装版 V2016年3月 系统概述 深度技术ghost win7系统64位j极速安装版 版 ...