Paper.Yellow
게시판 글쓰기 본문
글쓰기 칸을 꾸미기 위해 소스를 가져온다.
여러가지 있지만 예제로 우선 Summernote로 적용해본다.
Summernote - Super Simple WYSIWYG editor
Super Simple WYSIWYG Editor on Bootstrap Summernote is a JavaScript library that helps you create WYSIWYG editors online.
summernote.org
파일을 설치하지 않고 주소로 가져온다.
여러가지 버전을 제공하고 있다.
전체 코드 중에 현재 사용하고 있는 bootstrap5 버전 코드가 중복 될 수 있으니 중복되지 않는 것만 복사해서 가져온다.
바로 가져오면 오류가 날 수 있기 때문에 선 테스트 필수
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Summernote</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
</head>
<body>
<div id="summernote"></div>
<script>
$('#summernote').summernote({
height: 300
});
</script>
</body>
</html>
코드를 가져와서 사용해본다.
적용하기 전에 항상 선테스트!!!
$("#btnUpdate").click(()=>{
//update();
saveTest();
});
function updateTest(){
let data = {
title: $("#title").val(),
content: $("#content").val()
};
console.log(data.content);
}
값이 제대로 들어왔다는 콘솔 창 캡처 필요
null에 이름 붙이는 법
1) DB에서 if 걸어서 치환해서 가져올 수 있다.
SELECT if(usersId IS NULL, '익명', usersId) FROM boards;
2) service에서 치환해서 set해서 가져오기
3)Dto에서 get으로 지정
public String getUsername(){
return username == null ? "익명" : username;
}
4)뷰에서 코드 짜기
'Spring Boote' 카테고리의 다른 글
스프링부트 h2 데이터베이스 sql 자동 실행 (0) | 2022.11.18 |
---|---|
JSTL <c:forEach> (0) | 2022.10.12 |
자바스크립트 코드 리팩토링 (0) | 2022.09.16 |
Ajax (0) | 2022.09.15 |
복습 (0) | 2022.09.13 |