본문 바로가기

Web/front

[Thymeleaf docs] 4.4 Link URLs

728x90

 

틀린 해석이 있다면 알려주세요

 


 

공식문서를 제일 1순위로 공부해야겠다고 짚어주셨던 부분 중 하나가 바로 이것이다

 

타임리프 href 사용 할때 혹시

 

th:href="@{|http://localhost:8080/test/order/details(orderId=${o.id})|}"

이렇게 사용해본 적 있는 사람??

 

뭐가 잘못된건데 라고 한다면 

바로 이 "|" 이걸 사용한 것이다

 

공식문서에 따르면 th:href 를 사용할 때

 

이런 방식을 사용하라고 알려주고 있다

<!-- Will produce 'http://localhost:8080/gtvg/order/details?orderId=3' (plus rewriting) -->
<a href="details.html" 
   th:href="@{http://localhost:8080/gtvg/order/details(orderId=${o.id})}">view</a>

<!-- Will produce '/gtvg/order/details?orderId=3' (plus rewriting) -->
<a href="details.html" th:href="@{/order/details(orderId=${o.id})}">view</a>

<!-- Will produce '/gtvg/order/3/details' (plus rewriting) -->
<a href="details.html" th:href="@{/order/{orderId}/details(orderId=${o.id})}">view</a>

 

 

나만 그렇다고 할 수 없는게

나도 블로그 포스팅 복붙하다가 쓰게된 방법이기 때문이다.

 

 

 

| | << 이걸 쓸 상황은 바로 공식문서에 나와있다

  • Text operations:
    • String concatenation: +
    • Literal substitutions: |The name is ${name}|

 

 

 

 

하나 더..

 

 

서버 루트 상대 URL

추가 구문을 사용하여 동일한 서버의 다른 컨텍스트에 연결하기 위해 서버 루트 상대(컨텍스트 루트 상대 대신) URL을 만들 수 있습니다. 이러한 URL은 다음과 같이 지정됩니다.@{~/path/to/something}

 

 

css 경로 js 경로 같은 resource 불러올 때 

../

../../ 이런거 한 사람?

은 나야나ㅎㅎ... 

 

 

 

공식문서를 보자.... ㅠㅠ

 

 

 

728x90