annotation

SPRING

Custom Annotation 기반으로 Session 정보 가져오기

@GetMapping("/") public String index(Model model, HttpSession httpSession) { SessionUser user = (SessionUser) httpSession.getAttribute("user"); if(user != null) { model.addAttribute("loginUserName", user.getName()); } return "index"; } SessionUser user = (SessionUser) httpSession.getAttribute("user"); 에 대한 부분을 메소드 인자로 세션값을 바로 받을 수 있도록 변경 LoginUser package com.dolzi.config.auth; import java.lang...

SPRING

JPA Annotation

@NoArgsConstructor @Entity public class Posts { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(length = 500, nullable = false) private String title; @Column(columnDefinition = "TEXT", nullable = false) private String content; private String author; @Builder public Posts(String title, String content, String author) { this.title = title; this.content = content; th..

SPRING

Lombok Annontation

@Getter 선언된 모든 필드의 get 메소드를 생성 @Setter 선언된 모든 필드의 set 메소드를 생성 @RequiredArgsContstructor 선언된 모든 final 필드가 포함된 생성자를 생성 final이 없는 필드는 생성자에 포함되지 않음 @NoArgsConstructor 기본 생성자 자동 추가 public 클래스() {} @Builder 해당 클래스의 빌더 패턴 클래스 생성 생성자 상단에 선언 시 생성자에 포함된 필드만 빌더에 포함

dolzi
'annotation' 태그의 글 목록