liuxuejin 2011-08-14 10:39
浏览 559
已采纳

springMVC对静态资源的拦截问题

无论我怎么陪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
静态资源就无法获得!求大神解释

  • 写回答

3条回答 默认 最新

  • hyperprice 2011-08-15 09:49
    关注

    如果web.xml中spring mvc配置的过滤是[color=red]/[/color]的话. 可以如下配置:


    default
    *.css

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.gif</url-pattern>
    </servlet-mapping>
    

    类推 把所有静态放进来即可

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号