Karlie_dev
{SourceCode}
Karlie_dev
전체 방문자
오늘
어제
  • 분류 전체보기
    • 컴퓨터공학
    • JAVA
    • CSS
    • 자바스크립트
    • 파이썬
    • 스프링
    • DB
      • SQL
      • MySQL
      • Oracle
      • MongoDB
      • MariaDB
    • 형상관리
    • IDE
      • VS Code
      • Eclipse
    • 알고리즘
    • Server
    • AWS
    • 개발소리
    • Docker&Kubernetes
    • Cloud (클라우드)

블로그 메뉴

  • 홈

공지사항

인기 글

태그

  • mariadb
  • JavaScript
  • 쿠버네티스
  • 자바스크립트
  • docker
  • Minikube
  • MySQL
  • 마리아디비
  • 파이썬
  • 도커
  • kubernetes
  • k8s
  • MongoDB
  • 스프링
  • 오라클
  • oracle
  • AWS
  • 스프링부트
  • nodejs
  • Spring

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
Karlie_dev

{SourceCode}

스프링

Interceptor 스프링 적용 에러

2018. 3. 2. 23:35

예제를 보고 또다른 예제를 생성하고 스프링 셋팅 도중 오류가 터졌다.


심각: StandardWrapper.Throwable

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 65 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 65; columnNumber: 16; cvc-complex-type.2.4.a: 'interceptors' 요소로 시작하는 부적합한 콘텐츠가 발견되었습니다. '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' 중 하나가 필요합니다.


읽어보면, 스프링 셋팅을 위해 spring-servlet.xml에 넣은 interceptors를 가리키고 있다.


1
2
3
4
5
6
<interceptors>
        <interceptor>
            <mapping path="/{id}/admin"></mapping>
            <bean class="com.javaex.interceptorex.admin.AdminInterceptor"></bean>
        </interceptor>
</interceptors>
Colored by Color Scripter
cs


오류 원인 : bean의 namespace 설정


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 복사해서 가져온 예제의 bean
<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:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
        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">
 
// 현재 적용한(오류 발생한) 예제의 bean
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p" 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.1.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
    xmlns:mvc="http://www.springframework.org/schema/mvc">
Colored by Color Scripter
cs


보기 어렵지만, 중요한 포인트는

복사해서 가져온 예제는 xsi:schemaLocation="http://www.springframework.org/schema/mvc"

현재 오류가 발생한 예제는 xmlns:mvc="http://www.springframework.org/schema/mvc" 이 되어 있는 것이 다르다.


위 예제는 단순히 interceptors를 불렀지만, 아래 예제는 schema/mvc 를 mvc라는 ns에서 쓰겠다고 선언해놓았으므로 interceptors는 mvc 아래에 정의되어 있는 것이다. 위와 같은 경우에는 앞에 mvc: 를 붙여주면 해결된다.



1
2
3
4
5
6
<mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/{id}/admin"></mvc:mapping> 
            <bean class="com.javaex.interceptorex.admin.AdminInterceptor"></bean>
        </mvc:interceptor>
</mvc:interceptors>
Colored by Color Scripter
cs


저작자표시 (새창열림)
    '스프링' 카테고리의 다른 글
    • Spring Security 사용 중, POST 요청 시 403 뜨는 경우
    • 스프링 MariaDB log4jdbc 연결 오류 해결
    • ajax 406 에러 대응
    • 클라이언트와 서버의 관계
    Karlie_dev
    Karlie_dev

    티스토리툴바