티스토리 뷰
반응형
HTML
- JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> <!DOCTYPE html>
<html></html>
- Thymeleaf
<!DOCTYPE html> <html lang="ko" xmlns:th="http://www.thymeleaf.org">
Security
- JSP
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="isAnonymous()">
This content is only shown to anonymous users.
</sec:authorize>
<sec:authorize access="isAuthenticated()">
This content is only shown to authenticated users.
</sec:authorize>
- Thymeleaf
<html
lang="ko"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
></html>
<div sec:authorize="isAuthenticated()">
This content is only shown to authenticated users.
</div>
<div sec:authorize="hasRole('ROLE_ADMIN')">
This content is only shown to administrators.
</div>
<div sec:authorize="hasRole('ROLE_USER')">
This content is only shown to users.
</div>
Include
- JSP
<%@ include file="/WEB-INF/views/common/head.jsp"%>
- Thymeleaf
<div th:replace="/common/head :: head"></div>
href
- JSP
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
- Thymeleaf
<link th:href="@{/vendor/bootstrap/css/bootstrap.min.css}" rel="stylesheet" />
script
- JSP
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
- Thymeleaf
<script
type="text/javascript"
th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"
></script>
onclick
- JSP
<button onclick="location.href='addForm.html'" type="button">등록</button>
- Thymeleaf
<button th:onclick="|location.href='@{/basic/items/add}'|" type="button">
등록
</button>
- th:href="@{/basic/items/{itemId}(itemId=${item.id})}"
- th:href="@{/basic/items/{itemId}(itemId=${item.id},
query='test')}" - th:href="@{|/basic/items/${item.id}|}"
for
- JSP
<c:forEach items="${items}" var="item">
<tr>
<td>
<a href="/basic/items/" + ${itemId}> <c:out value="${item.id}" /></a>
</td>
<td><a href="/basic/items/" + ${itemId}"> <c:out value="${item.itemName}" /></a></td>
<td>${item.price}</td>
<td>${item.quantity}</td>
</tr>
</c:forEach>
- Thymeleaf
<tr th:each="item : ${items}">
<td>
<a
th:href="@{/basic/items/{itemId} (itemId=${item.id})}"
th:text="${item.id}"
>회원id</a
>
</td>
<td>
<a th:href="@{|/basic/items/${item.id}|}" th:text="${item.itemName}"
>상품명</a
>
</td>
<td th:text="${item.price}">10000</td>
<td th:text="${item.quantity}">10</td>
</tr>
input value
- JSP
<input
type="text"
id="itemId"
name="itemId"
class="form-control"
value="1"
readonly
/>
- Thymeleaf
<input
type="text"
id="itemId"
name="itemId"
class="form-control"
value="1"
th:value="${item.id}"
readonly
/>
ing
- JSP
- Thymeleaf
반응형
'Web > Spring' 카테고리의 다른 글
[Spring] 스프링 핵심 원리 - 기본편 강의 노트 (0) | 2021.05.27 |
---|---|
[SpringBoot] Security Login/Logout Page (0) | 2021.05.15 |
Spring Boot MVC 특징 (0) | 2021.04.30 |
Github에 있는 SpringBoot(maven, gradle) Project Repository import하기(STS, Eclipse) (3) | 2021.04.26 |
Local에 있는 SpringBoot(maven, gradle) project import하기(STS, Eclipse) (0) | 2021.04.26 |
댓글