Exception
[Exception] Invoking afterPropertiesSet() on bean with name 'xxxxxx'
헤르메스의날개
2022. 12. 28. 01:13
728x90
개발환경
Spring 4.3.30.RELEASE
MAVEN 3.8.4
Logback 1.2.9
AbstractView를 상속받은 FileDownload View를 구현 하고 Call 하는 구간에서 오류 발생
01:01:49.740 [http-nio-9090-exec-9] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'fileDownload'
01:01:49.740 [http-nio-9090-exec-9] DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'fileDownload'; URL [/WEB-INF/view/fileDownload.jsp]] in DispatcherServlet with name 'dispatcher'
01:01:49.740 [http-nio-9090-exec-9] DEBUG org.springframework.web.servlet.view.JstlView - Added model object 'downloadFile' of type [java.io.File] to request in view with name 'fileDownload'
01:01:49.740 [http-nio-9090-exec-9] DEBUG org.springframework.web.servlet.view.JstlView - Added model object 'orgnFileName' of type [java.lang.String] to request in view with name 'fileDownload'
01:01:49.740 [http-nio-9090-exec-9] DEBUG org.springframework.web.servlet.view.JstlView - Added model object 'org.springframework.validation.BindingResult.downloadFile' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'fileDownload'
01:01:49.740 [http-nio-9090-exec-9] DEBUG org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/view/fileDownload.jsp] in InternalResourceView 'fileDownload'
01:01:49.741 [http-nio-9090-exec-9] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
원인
AbstractView를 상속받은 View 파일을 생성하고, BeanNameViewResolver 선언하지 않았기 때문에 발생하는 문제입니다.
BeanNameViewResolver 와 UrlBasedViewResolver 중 BeanNameViewResolver 를 우선순위 높게 먼저 선언해야 합니다.
<!-- beanNameResolver는 우선순위를 0으로 해서 ViewPage를 찾을 때 우선 탐색한다.
만약 BeanNameViewResolver에서 없으면 UrlBasedViewResolve에서 탐색한다. -->
<bean id="beanNameResolver" class="org.springframework.web.servlet.view.BeanNameViewResolver">
<property name="order" value="0"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" /> <!-- 순서를 지정하는 property -->
</bean>
<bean id="fileDownload" class="simple.spring.view.FileDownloadView" />
728x90