λ¬Έμ
<li>
<input class="btn-cancel" type="button"
onClick="window.location = '/auth/login.do'"
value="<spring:message code='auth.register.cancel'/>" />
</li>
νμκ°μ μ·¨μ λ²νΌμ ν΄λ¦νλ©΄ λ‘κ·ΈμΈ νμ΄μ§λ‘ μ΄λνλλ‘ κ΅¬ννμ§λ§, 404μ€λ₯κ° λ°μνλ€
window.location = '/auth/login.do' λ‘, μ λ κ²½λ‘λ₯Ό μ¬μ©νκ³ μμλ€.
μ€μ μνλ κ²½λ‘λ 'http://location:8080/MyApp/auth/login.do' μμ§λ§, 'http://localhost:8080/auth/login.do'λ‘ μλͺ» 맀νμ΄ λκ³ μμλ€.
ν΄κ²° λ°©λ² : <c:url> μ¬μ©νκΈ°
JSPμ <c:url> νκ·Έλ₯Ό μ¬μ©νλ©΄ μλμΌλ‘ 컨ν μ€νΈ κ²½λ‘(Context Path)λ₯Ό ν¬ν¨νμ¬ μ¬λ°λ₯Έ κ²½λ‘λ‘ μ΄λν μ μλ€.
<li>
<input class="btn-cancel" type="button"
onClick="window.location = '<c:url value='/auth/login.do' />'"
value="<spring:message code='auth.register.cancel'/>" />
</li>
μ μ½λλ μ€νλ λ window.location = '/MyApp/auth/login.do'λ‘ λ³νλλ€.
<c:url> νκ·Έλ?
<c:url>μ JSPμμ λμ μΈ URLμ μμ±νλ νκ·Έλ‘, νμ¬ μ ν리μΌμ΄μ μ 컨ν μ€νΈ κ²½λ‘(Context Path)λ₯Ό μλμΌλ‘ ν¬ν¨ν΄μ€λ€.
μ΄λ‘ μΈν΄ μ ν리μΌμ΄μ μ λ°°ν¬ μμΉκ° λ°λλλΌλ URLμ΄ μλμΌλ‘ μ‘°μ λμ΄, μλͺ»λ κ²½λ‘λ‘ μ΄λνλ λ¬Έμ λ₯Ό λ°©μ§ν μ μλ€.
μ 리
μλ²μ λ©μΈ URLμ΄ localhost:8080/MyApp/μ΄κΈ° λλ¬Έμ /auth/login.doλ§ μΌμ λ, /MyApp/ λΆλΆμ΄ λΉ μ Έμ 404 μ€λ₯κ° λ°μν κ²μ΄λ€.
<c:url>μ μ¬μ©νλ©΄ μλμΌλ‘ /MyApp/μ λΆμ¬μ€μ μ μμ μΌλ‘ κ²½λ‘κ° μ΄λν μ μλ€.