프로젝트 정리/스프링과 JPA 기반 웹 애플리케이션 개발
37. 관심 주제 등록 기능 구현
JunGi Jeong
2022. 1. 1. 20:55
타임리프 자바스크립트 템플릿
<script type="application/javascript" th:inline="javascript"> </script> |
- https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#javascript-inlining
- Escaped: [[${variable}]]
- Unescaped: [(${variable})]
- 네추럴 템플릿: /*[[${variable}]]*/ null;
Ajax 호출시 CSRF 토큰을 전달 하는 방법
타임리프 자바스크립트 템플릿으로 Ajax 호출시 CSRF 토큰 설정
<script type="application/javascript" th:inline="javascript">
$(function() {
var csrfToken = /*[[${_csrf.token}]]*/ null;
var csrfHeader = /*[[${_csrf.headerName}]]*/ null;
$(document).ajaxSend(function (e, xhr, options) {
xhr.setRequestHeader(csrfHeader, csrfToken);
});
});
</script>
실습
- 시작 커밋: https://github.com/devjun63/whiteship-studyolle/commit/f12a680799157375ae4f2f1d33524cd2d149f3cb
- 완료 커밋: https://github.com/devjun63/whiteship-studyolle/commit/839a4575ddd2df78208ebfe7cd20cc0f50e86d3f
35. 관심 주제 도메인 · devjun63/whiteship-studyolle@f12a680
tag Entity 생성 Account -> Tag ManyToMany Account에서 Tag를 참조 (단방향)
github.com
37. 관심 주제 등록 기능 구현 · devjun63/whiteship-studyolle@839a457
Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files 37. 관심 주제 등록 기능 구현 Loading branch information Showing 8 changed files with 174 additions and 8 dele
github.com