온라인 강좌/유튜브 강의

Spring Boot 10. JPA를 이용하여 @OneToMany 관계 설정하기

Board.java @Entity @Data public class Board { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Valid @Size(min=2, max=30, message = "제목은 2자이상 30자 이하입니다.") private String title; private String content; @ManyToOne @JoinColumn(name = "user_id") @JsonIgnore private User user; } 게시글 입장에서 User와 다대일 관계이기 때문에 @ManyToOne 어노테이션 설정 join할 컬럼명은 Board테이블의 user_id @JsonIgnore를 통해 직렬화할 ..

온라인 강좌/유튜브 강의

Spring Boot 9. Spring Security를 이용한 로그인 처리

목표 1. Password Encode 구현 2. 로그인 했을 때/안했을 때에 따른 로그인 구현 register.html 회원가입 Username Password 회원가입 © 2017-2020 username과 password를 입력 후 회원가입 버튼을 누르면 /account/register 요청 발생 AccountController @Controller @RequestMapping("/account") public class AccountController { @Autowired private UserService userService; @GetMapping("/login") public String login(){ return "account/login"; } @GetMapping("/register..

온라인 강좌/유튜브 강의

Spring Boot 8. JPA를 이용한 페이지 처리 및 검색

BootStarp version : 4.5.3 BootStrap에서 기본 페이징 nav를 가져온다. Previous 1 2 3 Next BoardController @GetMapping("/list") public String list(Model model, @PageableDefault(size = 2) Pageable pageable, @RequestParam(required = false, defaultValue = "") String searchText){ Page boards = boardRepository.findByTitleContainingOrContentContaining(searchText, searchText, pageable); int startPage = Math.max(1, bo..

온라인 강좌/유튜브 강의

Spring Boot 7. JPA를 이용한 RestfulAPI 작성

@GetMapping : 조회 @PostMapping : 추가(insert) @PutMapping : 수정(update) @DeleteMapping : 삭제 JPA를 통해 지정할 수 있는 규칙을 통해 검색 구현 JPA Query Methods :: Spring Data JPA As of Spring Data JPA release 1.4, we support the usage of restricted SpEL template expressions in manually defined queries that are defined with @Query. Upon the query being run, these expressions are evaluated against a predefined set of var..

온라인 강좌/유튜브 강의

Spring Boot 6. thymeleaf에서 form 전송하기

Handling Form Submission Form Id: Message: post 요청으로 form의 내용을 보낼 주소 object로 지정하면 controller에서 지정했던 greeting 키 사용 가능 에서 "*{id}" 하게 되면 greeting.id 값이 들어옴 글 수정하기 list.html Mark Otto 홍길동 title을 누르면 board의 id 값을 함께 보낸다. (Controlelr에서 RequestParam 추가) BoardController @GetMapping("/form") public String form(Model model, @RequestParam(required = false) Long id){ if(id == null){ model.addAttribute("boar..

범박사
'분류 전체보기' 카테고리의 글 목록 (4 Page)