[Tymeleaf] URL 링크 ( th:href="@~" )
2024. 10. 16. 23:43ㆍJAVA 기반 웹개발/ThymeLeaf
URL 링크
public String link(Model model){
model.addAttribute("param1", "data1");
model.addAttribute("param2", "data2");
return "basic/link";
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Thymeleaf 테스트 </title>
</head>
<body>
<ul>
<li><a th:href="@{/hello}"> /hello </a></li>
<li><a th:href="@{/hello(param1=${param1}, param2=${param2})}"> /hello?param1=data1¶m2=data2</a></li>
<li><a th:href="@{/hello/{param1}/{param2}(param1=${param1}, param2=${param2}">/hello/data1/data2 </a></li>
<li><a th:href="@{/hello/{param1}(param1=${param1} ,param2=${param2})}"> /hello/data1?param2=data2</a></li>
</ul>
</body>
</html>
- @를 이용하여, URL을 표현
- @{/hello}
- /hello
- @{/hello(param1=${param1}, param2=${param2})}
- /hello ? param1=data1 & param2=data2
- @{/hello/{param1}/{param2}(param1=${param1}, param2=${param2}"
- /hello/data1/data2
- @{/hello/{param1}(param1=${param1} ,param2=${param2})}
- /hello/data1?param2=data2
- @{/hello}
'JAVA 기반 웹개발 > ThymeLeaf' 카테고리의 다른 글
[Thymeleaf] 연산 표현 (연산, 조건 , elvis, no-opration) (0) | 2024.10.17 |
---|---|
[Thymeleaf] 리터럴 (상수) (0) | 2024.10.16 |
[Tymeleaf] 지역변수 선언 (th:with) (0) | 2024.10.16 |
[Thymeleaf] 데이터 출력 (0) | 2024.10.16 |