-
Spring - Servelt 설정변경기초/SPRING 2020. 8. 28. 11:29
WEB-INF > web.xml 변경
welcom tag 추가
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list>
servelt 태그변경
<servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
을 아래와 같이 변경
<servlet> <servlet-name>action</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/*-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.dg</url-pattern> </servlet-mapping>
url-pattern : 확장자를 jsp가 아닌 dg ( 프로젝트에 맞게 변경 가능 )
init-param : servlet.xml을 확정성이 용이하게 변경
context-param 변경
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/root-context.xml</param-value> </context-param>
을 아래와 같이 변경
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:config/spring/context-*.xml</param-value> </context-param>
root-context를 servlet-context.xml 파일이 아닌 다른곳에서 설정
또한 context들을 분할하여 관리 ( 향후 DB, INTERCEPTOR 등 추가예정 )
servlet-context.xml을 action-servlet.xml로 변경
old : WEB-INF > spring > appServlet > servlet-context.xml
new : WEB-INF > config > action-servlet.xml
이후 spring 폴더 삭제
'기초 > SPRING' 카테고리의 다른 글
[Spring] Mysql 계층적 쿼리구조 (0) 2020.09.23 [Spring] Maria DB 연결+SQL LOG (0) 2020.09.09 Spring - Interceptor 적용 (0) 2020.08.28 부트스트랩 적용 및 resources 지정 (0) 2020.08.28 타일즈 적용 (0) 2020.08.26