解决Spring MVC DispatcherServlet拦截“/”时,无法访问静态资源的问题
2017-07-15 09:15
615 查看
原文地址:http://lzy83925.iteye.com/blog/1186609
方式一:激活Tomcat的defaultServlet来处理静态文件
方式二:使用标签
方式三:使用
方式四:DispatcherServlet拦截”*.do”
方式一:激活Tomcat的defaultServlet来处理静态文件
<!--web.xml--> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> <!--其他静态资源如*.css、*.jpg同上--> <!--写在DispatcherServlet的前面-->
方式二:使用标签
<mvc:resources/>
<!--springmvc-servlet.xml--> <?xml version="1.0" encoding="UTF-8"?> <!--注意头文件--> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd"> <mvc:resources location="/js/" mapping="/js/**"/><!--location为静态资源本地路径--> <!--省略其他--> </beans>
方式三:使用
<mvc:default-servlet-handler/>
<!--springmvc-servlet.xml--> <mvc:default-servlet-handler/>
方式四:DispatcherServlet拦截”*.do”
相关文章推荐
- 解决Spring MVC整合Shiro出现无法访问静态资源文件的问题
- 解决spring mvc静态资源无法访问的问题
- 解决tomcat无法访问webapp下面的静态资源问题
- spring mvc3 静态文件放在WEB-INF下无法访问解决和解决@Controller失效问题
- web项目中url-pattern改成'/'后,js、css、图片等静态资源(404)无法访问问题解决办法
- springmvc中静态资源无法访问问题
- nodejs 构建本地web测试服务器 以及 解决访问静态资源的问题!有完整源码!
- 解决 伪静态中真正html无法访问的问题
- springMVC无法访问静态资源问题
- 解决模拟器无法访问网络资源问题
- spring mvc静态资源拦截问题
- Spring3中js/css/jpg/gif等静态资源无法找到(No mapping found for HTTP request with URI)问题解决
- 如何解决服务器能够ping通 但是无法访问资源的问题
- Spring3中js/css/jpg/gif等静态资源无法找到(No mapping found for HTTP request with URI)问题解决
- Nginx 访问静态资源报错404 Not Found 的问题解决过程
- 使用SSM创建项目后,无法访问静态资源,报404错误解决办法
- Spring3中js/css/jpg/gif等静态资源无法找到(No mapping found for HTTP request with URI)问题解决
- Spring3中js/css/jpg/gif等静态资源无法找到(No mapping found for HTTP request with URI)问题解决
- Spring3中js/css/jpg/gif等静态资源无法找到(No mapping found for HTTP request with URI)问题解决
- Windows XP无法访问网络资源各种问题分析及解决方法