JavaSpringMVC模式定位导致404错误

JavaSpringMVC模式定位导致404错误,java,spring,spring-mvc,Java,Spring,Spring Mvc,看看如何实现一个非常基本的JavaSpring应用程序。目前,我正在尝试在视图中包含js/css文件。当我在schemaLocation下的mvc-dispatcher-servlet.xml文件中添加必要的信息时,我的站点抛出一个404错误 mvc-dispatcher-servlet.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http:

看看如何实现一个非常基本的JavaSpring应用程序。目前,我正在尝试在视图中包含js/css文件。当我在schemaLocation下的mvc-dispatcher-servlet.xml文件中添加必要的信息时,我的站点抛出一个404错误

mvc-dispatcher-servlet.xml

    <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
--breaks things http://www.springframework.org/schema/mvc
--breaks things  http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="com.pkg"/>
        <mvc:resources mapping="/resources/**" location="/resources/css/" />

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

xml依赖项调用

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>

朱尼特
朱尼特
4.11
测试
看法



尝试删除前面的斜杠。您指的是什么斜杠?mvc:resources中映射和值属性中的斜杠“/”。tagI尝试了该行中的所有斜杠组合。。仍然收到来自浏览器的404错误。但是在tomcat控制台中没有什么有用的东西。当我在schemaLocation中添加schema/mvc URL时抛出了404。不过我认为您的思路是正确的。在我删除该行后,页面加载。让我来玩玩,看看能不能让它发挥作用。
 <link href="<c:url value="/resources/css/file.css" />" rel="stylesheet">