서버
[Apache-Tomcat] Tomcat Context 경로 설정
Hambeer
2024. 1. 8. 15:36
conf
폴더 내의 server.xml
파일에서 <Host>
내의 <Context>
에서 파일경로의 변경이 가능
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="firstDoc" path="/" reloadable="true" />
<Context docBase="secondDoc" path="/hello" reloadable="true" />
</Host>
<Host>
태그 의 name에서 host를 설정 가능하다.
위의 예시의 경우 appBase로 부터 시작하는 상대경로이므로 [Tomcat 설치디렉토리]/webapps
가 기본 디렉토리가 된다.
<Host>
태그 내에 있는 윗줄 <Context>
태그를 본다면
<Context docBase="firstDoc" path="/" reloadable="true" />
http://localhost/hello.jsp 를 요청할 경우, http://localhost/firstDoc/hello.jsp 을 출력한다.
두 번째 예시로
<Context docBase="secondDoc" path="/hello" reloadable="true" />
http://localhost/hello/hello.jsp 를 요청할 경우, http://localhost/secondDoc/hello.jsp 을 출력한다.