JSP & ThymeLeaf

Thymeleaf 경로 처리 (URL 처리)

낙산암 2022. 4. 2. 16:15

■ Absolute URL (절대 경로)

 

- 특정 url로 직접 이동이 가능

<a th:href="@{http://www.thymeleaf/documentation.html}">


■ Context-relative URL

 

- 우리 서버 내 특정 위치로 이동이 가능

- 서버 내 리소스 /order/list

<a th:href="@{/oreder/list}">

 

■ Adding Parameter URL

 

https://www.test.io/order/details?id=1

<a th:href="@{/oreder/details(id=1)}">

 

파라미터를 여러개 사용하기 위해서는 아래와 같이 쉼표로 구분합니다.

<a th:href="@{/oreder/details(id=1, action='show_all')}">

 

■ Server-relative URL

 

Server-relative URLs are very similar to context-relative URLs, except they do not assume you want your URL to be linking to a resource inside your application’s context, and therefore allow you to link to a different context in the same server:

<a th:href="@{~/billing-app/showDetails.htm}">

The current application’s context will be ignored, therefore although our application is deployed at http://localhost:8080/myapp, this URL will output:

<a href="/billing-app/showDetails.htm">

Protocol-relative URLs

Protocol-relative URLs are in fact absolute URLs which will keep the protocol (HTTP, HTTPS) being used for displaying the current page. They are typically used for including external resources like styles, scripts, etc.:

<script th:src="@{//scriptserver.example.net/myscript.js}">...</script>

…which will render unmodified (except for URL rewriting), like:

<script src="//scriptserver.example.net/myscript.js">...</script>


https://www.thymeleaf.org/doc/articles/standardurlsyntax.html

 

Standard URL Syntax - Thymeleaf

The Thymeleaf standard dialects –called Standard and SpringStandard– offer a way to easily create URLs in your web applications so that they include any required URL preparation artifacts. This is done by means of the so-called link expressions, a type

www.thymeleaf.org