1

当我在服务器上存在的 url 下方输入时,出现 404 错误

localhost/PDFDemo/resources/jquery/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png



Error 404--Not Found

From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:

10.4.5 404 Not Found

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

If the server does not wish to make this information available to the client, the status code `403 (Forbidden)` can be used instead. The `410 (Gone)` status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.

我对 javascript 文件有同样的问题,并通过在 web.xml 中添加以下内容解决了这个问题

<mime-mapping>
        <extension>js</extension>
        <mime-type>text/javascript</mime-type>
    </mime-mapping>

是否有我可以放入的 jsp 和图像的等效代码contextConfigLocation(例如:servlet.xml)。

4

1 回答 1

0

问题是您将 Spring Dispatcher Servlet 映射到根上下文,因此 Spring 想要处理每个请求(如果配置正确,这本身就不是问题)。添加如下内容:

<mvc:resources mapping="/resources/**" location="/public-resources/" cache-period="31556926"/>

为您的环境修改应该可以工作。请参阅允许静态资源绕过 Spring 的文档并在此处转到默认 servlet 。

您还应该将此添加到您的配置中,以便 Spring 知道使用默认 Servlet。

<mvc:default-servlet-handler/>

此外,这个问题的答案可能会对您有所帮助。

于 2012-10-19T15:43:28.430 回答