0

请帮我解决以下问题!我有配置:

<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/css/" mapping="/css/**"/>
<mvc:resources location="/javascript/" mapping="/javascript/**"/>

在以下请求中,我的资源一切正常:

http://127.0.0.1:8080/baraholka/viewAdverts.brh

但是当我有这样的要求时:

http://127.0.0.1:8080/baraholka/viewTagAdverts/tag/2/1

在哪里:

@RequestMapping(value="/ajaxViewAdverts/tag/{id}/{currentPage}",      method=RequestMethod.GET)
    public ResponseEntity<byte[]> viewTagAdverts(@PathVariable("id") Integer id, @PathVariable(value="currentPage") Integer currentPage, ModelMap map, HttpServletRequest request, HttpServletResponse response){
    byte view[] = {};
    HttpHeaders httpHeaders = new HttpHeaders();

我得到:

20:48:08.109  WARN [http-8080-4] org.springframework.web.servlet.DispatcherServlet:947  - No mapping found for HTTP request with URI     [/baraholka/viewTagAdverts/tag/2/javascript/jquery.cookies.2.2.0.js] in DispatcherServlet with name 'baraholka'
20:48:08.109  WARN [http-8080-3] org.springframework.web.servlet.DispatcherServlet:947 - No mapping found for HTTP request with URI [/baraholka/viewTagAdverts/tag/2/javascript/baraholka.js] in DispatcherServlet with name 'baraholka'
20:48:08.140  WARN [http-8080-1] org.springframework.web.servlet.DispatcherServlet:947 - No mapping found for HTTP request with URI [/baraholka/viewTagAdverts/tag/2/javascript/jquery.lightbox-0.5.min.js] in DispatcherServlet with name 'baraholka'
20:48:08.156  WARN [http-8080-5] org.springframework.web.servlet.DispatcherServlet:947 - No mapping found for HTTP request with URI [/baraholka/viewTagAdverts/tag/2/javascript/jquery.ui.stars.js] in DispatcherServlet with name 'baraholka'
20:48:08.156  WARN [http-8080-2] org.springframework.web.servlet.DispatcherServlet:947 - No mapping found for HTTP request with URI [/baraholka/viewTagAdverts/tag/2/css/jqcloud.css] in DispatcherServlet with name 'baraholka'
20:48:08.171  WARN [http-8080-3] org.springframework.web.servlet.DispatcherServlet:947 - No mapping found for HTTP request with URI [/baraholka/viewTagAdverts/tag/2/images/login.png] in DispatcherServlet with name 'baraholka'
20:48:08.171  WARN [http-8080-1] org.springframework.web.servlet.DispatcherServlet:947 - No mapping found for HTTP request with URI [/baraholka/viewTagAdverts/tag/2/images/logo.png] in DispatcherServlet with name 'baraholka'

如何设置正确的映射?我也尝试过像/images/这样的映射,但它不起作用。

4

2 回答 2

1

你也可以像这样添加你的资源:

<base href="http://localhost:8080/" />
<link rel="icon" href="resources/images/favicon.ico" type="ico">

这不是很好的解决方案,但我无法通过其他方式解决我的应用程序中的类似问题

于 2011-11-21T16:15:43.263 回答
0

我看起来您使用相对路径来引用模板中的静态资源,因此浏览器将它们视为相对于当前页面,正如您在日志中看到的那样。

您需要构建完整路径<c:url>,如下所示:

<script src = "<c:url value = "/javascript/baraholka.js" />"></script>
于 2011-11-20T18:43:02.980 回答