징어군
72
2021-04-16 21:53:36
2
66

servlet-config.xml에 <resources mapping="/resources/**" location="/resources/" /> 코드 추가 후 오류발생!


servlet-config.xml에 

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

코드를 추가하니 


이와 같은 오류가 발생했습니다. 

그런데 추가하기 전까지는 mapping이 잘 되었었기에 추가하기 전/후의 console을 확인해보니 appServlet 업로드하는 과정에서 mapping한 내용이 없어지는? 차이가 있었습니다. 


코드 추가 전 >

정보: Initializing Spring FrameworkServlet 'appServlet'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Apr 16 21:22:05 KST 2021]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2759c18f: defining beans [org.springframework.web.servlet.view.InternalResourceViewResolver#0,tilesConfigurer,tilesViewResolver,homeController,memberController,securityConfig,memberService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration,webSecurityExpressionHandler,springSecurityFilterChain,privilegeEvaluator,org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration,objectPostProcessor,org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration,authenticationManagerBuilder]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@5b41d54d
INFO : org.springframework.web.servlet.view.tiles2.TilesConfigurer - TilesConfigurer: adding definitions [/resources/tiles/tiles.xml]
INFO : org.apache.tiles.context.AbstractTilesApplicationContextFactory - Initializing Tiles2 application context. . .
INFO : org.apache.tiles.context.AbstractTilesApplicationContextFactory - Finished initializing Tiles2 application context.
INFO : org.apache.tiles.access.TilesAccess - Publishing TilesContext for context: org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext
INFO : org.springframework.security.web.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2df76218, org.springframework.security.web.context.SecurityContextPersistenceFilter@1729ffc9, org.springframework.security.web.header.HeaderWriterFilter@68ee2424, org.springframework.security.web.csrf.CsrfFilter@2181376d, org.springframework.security.web.authentication.logout.LogoutFilter@329e2e78, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@277b12bf, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@24a49a8b, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@10bcdd9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4657f100, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@378f5b14, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4c492d3b, org.springframework.security.web.session.SessionManagementFilter@404590de, org.springframework.security.web.access.ExceptionTranslationFilter@7aba1a00, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@d554913]
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Root mapping to handler 'homeController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/denied] onto handler 'homeController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/denied.*] onto handler 'homeController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/denied/] onto handler 'homeController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/join] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/join.*] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/join/] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/login] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/login.*] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/login/] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/idChk] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/idChk.*] onto handler 'memberController'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/idChk/] onto handler 'memberController'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 1521 ms


코드 추가 후 >

INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri Apr 16 21:20:04 KST 2021]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d2c4ecd: defining beans [org.springframework.web.servlet.view.InternalResourceViewResolver#0,tilesConfigurer,tilesViewResolver,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,homeController,memberController,securityConfig,memberService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration,webSecurityExpressionHandler,springSecurityFilterChain,privilegeEvaluator,org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration,objectPostProcessor,org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration,authenticationManagerBuilder]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@6c4ac28a
INFO : org.springframework.web.servlet.view.tiles2.TilesConfigurer - TilesConfigurer: adding definitions [/resources/tiles/tiles.xml]
INFO : org.apache.tiles.context.AbstractTilesApplicationContextFactory - Initializing Tiles2 application context. . .
INFO : org.apache.tiles.context.AbstractTilesApplicationContextFactory - Finished initializing Tiles2 application context.
INFO : org.apache.tiles.access.TilesAccess - Publishing TilesContext for context: org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
INFO : org.springframework.security.web.DefaultSecurityFilterChain - Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6e8e4b0b, org.springframework.security.web.context.SecurityContextPersistenceFilter@5999fee2, org.springframework.security.web.header.HeaderWriterFilter@12d05dde, org.springframework.security.web.csrf.CsrfFilter@977faf, org.springframework.security.web.authentication.logout.LogoutFilter@7e18ecd8, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@527ce5d5, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@220af7e5, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@5d52d42, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@d2cd563, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7a6d5d56, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3fe0f7e1, org.springframework.security.web.session.SessionManagementFilter@457a32c0, org.springframework.security.web.access.ExceptionTranslationFilter@deac744, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4ff186a4]
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 1580 ms



제가 servlet-config.xml에 <resources mapping="/resources/**" location="/resources/" /> 추가하는 과정에서 잘못한 거 같은데, 어디가 잘못된 것인지를 모르겠습니다. 도와주세요, 선배님들!!!



아래는 코드를 추가한 servlet-config.xml내용입니다!

<?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:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc 
		https://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans 
		https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context 
		https://www.springframework.org/schema/context/spring-context.xsd">


	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<beans:property name="prefix" value="/WEB-INF/views/" />
		<beans:property name="suffix" value=".jsp" />
		<beans:property name="order" value="2" />
	</beans:bean>
	
	<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <beans:property name="definitions">
            <beans:list>
                <beans:value>/resources/tiles/tiles.xml</beans:value>
            </beans:list>
        </beans:property>
    </beans:bean>
    
    <beans:bean id="tilesViewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
        <beans:property name="order" value="1" /> 
    </beans:bean>
	
	<context:component-scan base-package="com.project.프로젝트명" />
	

	<!-- 추가한 코드 -->
	<resources mapping="/resources/**" location="/resources/" />


</beans:beans>



0
  • 답변 2

  • 방황하는젊은이
    1k
    2021-04-17 05:48:50

    <mvc:resources/>

  • 징어군
    72
    2021-04-17 19:00:02
    제가 디폴트 네임스페이스로 설정해서 그냥 <resources ...>로 해도 코드상 에러가 일어나지 않습니다...ㅠㅠ
  • 로그인을 하시면 답변을 등록할 수 있습니다.