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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵