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条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格