无论我怎么陪web.xml的拦截。/或者/uc/*我的静态资源都被拦截了。
yinhex
/uc/*
配置为:
< mvc:resources mapping="/javascripts/**"location="/javascripts/"/>
访问路径为: http://localhost:8080/yinhex/index/javascripts/jquery.bgiframe.js
index为controller的注解.为什么还是被拦截了呢???导致静态资源不可用
@Controller
@RequestMapping("/index")
public class IndexController{
@Resource(name="userService")
private UserService userService;
@RequestMapping(value = "index", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView mav = new ModelAndView();
System.out.println("---======11111我进来啦TestController");
User user = userService.login("liujiebinhe@126.com", "liuxuejin");
System.out.println("==============="+user.getUserName());
mav.addObject("test", "hello world!");
mav.setViewName("main");
System.out.println("---======11111我进来啦TestController");
return mav;
}
然后访问:
http://localhost:8080/yinhex/uc/index/index
的时候
}
http://localhost:8080/yinhex/uc/index/javascripts/jquery.bgiframe.js
静态资源就无法获得!求大神解释
如果web.xml中spring mvc配置的过滤是[color=red]/[/color]的话. 可以如下配置:
default
*.css
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
类推 把所有静态放进来即可
你的配置里已经配置了index,spring肯定先找你对应的controller,而不是先找静态资源了
静态资源的路径最好 不要跟controller的配置的路径相同
/uc/* 最好不要写/*,那样是默认拦截所在的请求,所以可以改写成一些自定义的后缀,比如/do等,你想要被spring拦截的后缀。。这样,你的静态资源就不会被拦截了。。