2015-02-04 3 views
0

의 mvc : resource를 인식하지 못합니다. 업데이트 : 이제 올바르게 작동합니다. 친절하게 의견을 따르십시오.
이 내 Spring 설정 파일입니다 : 모든 단지가이 프로젝트에 포함되어봄 MVC가 설정 파일

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    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="report.frontcontroller"/> 
    <mvc:resources mapping="/resources/**" location="/resources/" /> 
    <mvc:annotation-driven /> 
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix"> <value>/WEB-INF/</value></property> 
     <property name="suffix"> <value>.jsp</value></property> 
    </bean> 
</beans> 

, 구성 파일은 위에 표시됩니다. 나는이 부분에 대한 오류를 얻을 :

<mvc:resources mapping="/resources/**" location="/resources/" /> 
<mvc:annotation-driven /> 

오류 : *이 일치하는 와일드 카드가 엄격하지만 선언 mvc:resource을 찾을 수 없습니다되고 mvc:annotation * 여러 주석이 라인에서 찾을 : - cvc-을 complex-type.2.4.c : 일치하는 와일드 카드가 엄격하지만 'mvc : resources'요소에 대한 선언을 찾을 수 없습니다. - schema_reference.4 : 1) 문서를 찾을 수 없어 스키마 문서 'http://www.springframework.org/schema/mvc/spring- mvc-3.0.xsd'을 읽지 못했습니다. 2) 문서를 읽을 수 없습니다. 3) 문서 의 루트 요소가 아닙니다. 이 줄에서 여러 주석을 찾을 수 있습니다. * - cvc-complex-type.2.4.c : 일치하는 와일드 카드가 엄격하지만 'mvc : resources'요소에 대한 선언을 찾을 수 없습니다. - schema_reference.4 : 스키마 문서 'http://www.springframework.org/schema/mvc/spring- mvc.xsd'을 읽지 못했습니다. 1) 문서를 찾을 수 없으므로; 2) 문서를 읽을 수 없습니다. 3) 문서 의 루트 요소가 아닙니다.

+0

자체가 올바른 구성 파일에서 복사되는 구성 아래에 시도 할 수 있습니다 참조하십시오. Spring (MVC) 버전은 무엇입니까? – meskobalazs

+0

신청서에 어떤 스프링 용기가 있습니까? – Ralph

+0

의 spring-webmvc-4.1.1.RELEASE-sources와 다른 모든 jar도 같은 버전입니다. – user2677600

답변

-1

spring-mvc.xsd에서 spring-mvc-3.0.xsd으로 변경하십시오. 나머지 모든 장소도 마찬가지로 변경됩니다.

here

편집

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <context:component-scan base-package="report.frontcontroller" /> 
    <mvc:annotation-driven/> 
    <mvc:resources mapping="/resources/**" location="/resources/" /> 
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/views/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 
</beans> 
+0

나는 spring-mvc-4.1.1을 사용하고있다. 문서에 따르면 우리는 같은 버전의 항아리를 사용해야합니다. – user2677600

+0

예 .. 강조하고 싶은 부분이 아니므로 링크를 제공하십시오. 그 스레드에서보고 된 봄 버그. 어쨌든 위에 제안 된대로 xsd를 변경하면 문제가 해결됩니다. –

+0

그래서 모든 jar를 다운 그레이드해야합니까, 아니면 구성 파일을 변경해야만 작동할까요? 그게 당신이 위에서 제안한 것처럼 작동하지 않기 때문입니다. – user2677600

0

것은 당신이 GIT - spring-mvc-showcase

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:task="http://www.springframework.org/schema/task" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> 

    <resources mapping="/resources/**" location="/resources/" /> 

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

    <task:annotation-driven /> 

</beans:beans> 
+0

여전히 동일한 문제입니다 .. 이 줄에서 여러 주석을 찾을 수 있습니다 : \t - cvc-complex-type.2.4.c : 일치하는 와일드 카드는 엄격하지만 'mvc : resources'요소에 대한 선언을 찾을 수 없습니다. \t - schema_reference.4 : 스키마 문서 'http://www.springframework.org/schema/mvc/spring- \t mvc-3.0.xsd'을 읽지 못했습니다. 1) 문서를 찾을 수 없으므로; 2) 문서를 읽을 수 없습니다. 3) 문서의 루트 요소 \t이 이 아닙니다. – user2677600

+0

지금 실행 중입니다. 문제는 ips 즉 http://www.springframework.org/schema/mvc/spring-mvc.xsd 파일에 대한 요청을 차단하는 것과 같습니다. 로컬 용으로 다운로드하여 클래스 패스에 포함 시키거나 네트워크 엔지니어에게 요청을 차단하지 않도록 요청하는 두 가지 해결책이 있습니다. – user2677600

+0

이 파일은 spring jars에 포함되어 있습니다. 클래스 경로 또는 버전 충돌 문제가있을 수 있습니다. –