Tomcat8 Document Root
안녕하세요, 오늘은 Document Root에 대해 알아보도록 하겠습니다~
저번 시간에 우리는 welcome-file 태그를 이용해서 index.jsp 파일을 시작파일로 변경해보았습니다.
이때 말씀드린게, index.jsp 파일은 Document Root 아래 존재해야한다고 했었죠.
잘 기억이 안나신다면 아래 링크를 통해 보고 오시면 되겠습니다.
그렇다면 오늘 알아볼 Document Root 는 무엇일까요?
바로 Web의 최상의 경로 즉 Root 경로라고 할 수 있습니다.
이러한 경로는 Tomcat.../conf/server.xml을 통해 확인할 수 있어요!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> | cs |
하단에 보시면 위와 같이 코드가 있을겁니다.
<Host .... appBase="webapps" ... > 하고 명시되어 있는데 보입니다.
Tomcat의 Document Root 는 webapps/Root 가 Default path입니다.
webapps라고만 명시되어있더라도, webapps/Root로 잡혀있는거죠.
어렵죠?
지금부터 차근차근 설명해보도록 하겠습니다.
자 먼저,
에서 appBase가 Document Root 라고 말씀드렸습니다. 그렇다면 webapps 는 어디에 있는걸까요?
저 같은 경우는 다음 사진과 같은 위치에 잡혀있네요.
해당 위치로 가니 webapps가 보이네요.
네 바로 이 경로가 되겠습니다. 실제로는 ${CATALINA_HOME}/webapps 가 웹의 경로가 되는것이죠.
어떻게 보면 Document Root 는 물리적 위치를 나타내는 최상위 Root라고도 할 수 있겠네요.
webapps 폴더에 들어가면 뭐 특별한건 없습니다. ROOT 폴더가 보이긴 하죠.
여기까지 이해되셨나요?
그럼 무조건 Tomcat의 Document Root 는 webapps/Root 인걸까요?
그렇지 않습니다.
Context 태그를 사용하시면 Document Root를 변경하실 수 있습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context docBase="ErsGraph" path="/" reloadable="false" source="org.eclipse.jst.jee.server:ErsGraph"/> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> | cs |
위와 같이 Host 태그 사이에 Context 태그를 넣는다면 Document Root는 webapps/ROOT가 아닌, webapps/ErsGraph 가 되는거죠.
즉 Context의 docBase에 명시되어 있는 경로가 webapps/ 밑으로 들어오면서 Document Root 가 되는겁니다.
이렇게 하면 localhost:8080/ 로 검색해도 localhost:8080/ErsGraph가 나오겠죠?
하지만 이렇게 변경하는 방법은 잘 사용하지 않는다고 합니다.
더 좋은 방법은 다음 컨텐츠에서 공부해보도록 하겠습니다~
'Web' 카테고리의 다른 글
Spring DispatcherSevlet 동작 원리 Part1 (0) | 2019.02.05 |
---|---|
Include 지시어와 Include 액션의 차이 (0) | 2019.01.27 |
spring index.jsp 시작페이지 설정 (0) | 2019.01.10 |
Spring java.util.zip.ZipException: error in opening zip file 에러 (1) | 2019.01.08 |
Spring Tomcat 404 에러 (0) | 2019.01.07 |