Css 资源在 jsp 中不可用

Css resource not available in jsp

您好,我正在使用 spring,我想包含一个 css 文件。

我在 webapp.

下创建了文件夹 resources/mytheme/css/signing.css

我的调度程序 servlet 如下所示:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:component-scan base-package="com.springapp.mvc"/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <mvc:resources mapping="/resources/**" location="/resources/mytheme/" />

</beans>

在我的 jsp 文件中,我这样引用 css 文件:

<link href="${pageContext.request.contextPath}/resources/css/signing.css" rel="stylesheet" >

当我浏览该页面时,我总是收到 404 请求的资源不可用。

谁能帮帮我?

我通过将此添加到我的web.xml

解决了这个问题
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/resources/*</url-pattern>
</servlet-mapping>

这使我的资源文件夹可用。