SecurityConfig.java package inflearn.freejwt.config; import inflearn.freejwt.jwt.JwtAccessDeniedHandler; import inflearn.freejwt.jwt.JwtAuthenticationEntryPoint; import inflearn.freejwt.jwt.JwtSecurityConfig; import inflearn.freejwt.jwt.TokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.m..
build.gradle에 jwt 관련 코드를 추가 plugins { id 'java' id 'org.springframework.boot' version '2.4.1' // Spring Boot 버전을 2.4.1로 변경 id 'io.spring.dependency-management' version '1.0.10.RELEASE' // Spring Dependency Management 버전 변경 } group = 'inflearn' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } ..
SecurityConfig 에 추가 /** * h2-console 하위 모든 요청들과 파비콘 관련 요청은 * Spring Security 로직을 수행하지 않고 접근할 수 있게 configure 메서드를 오버라이드해서 내용을 추가해준다. */ @Override public void configure(WebSecurity web) { web.ignoring() .antMatchers( "/h2-console/**" ,"/favicon.ico" ); } Authority package inflearn.freejwt.entity; import lombok.*; import javax.persistence.Column; import javax.persistence.Entity; import javax.persis..
먼저, 앞서 나왔던 401 에러를 해결하기 위한 작업 (시큐리티가 들어가다 보니, 임포트까지 최대한 들어가게 옮기겠다.) SecurityConfig package inflearn.freejwt.config; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @EnableW..
# 비고 강의의 기본 세팅은 스프링 부트 2.4.1 이지만, 현재 스프링 부트 이니셜라이저는 2.7.15 버전부터 서비스되고 있기 때문에, 인위적으로 바꾸는 과정이 필요했다. 초기 : 2.7.15 build.gradle plugins { id 'java' id 'org.springframework.boot' version '2.7.15' id 'io.spring.dependency-management' version '1.0.15.RELEASE' } group = 'inflearn' version = '0.0.1-SNAPSHOT' java { sourceCompatibility = '1.8' } configurations { compileOnly { extendsFrom annotationProcesso..

셀렉트 박스 - 셀렉트 박스는 여러 선택지 중에 하나를 선택할 때 사용할 수 있다. - 이번시간에는 셀렉트 박스를 자바 객체를 활용해서 개발한다. 배송 방식 빠른 배송 일반 배송 느린 배송 셀렉트 박스로 하나만 선택할 수 있다. FormItemController 에 코드 추가 /** * 모델에 배송 코드 목록을 추가하는 메서드. * * @return 배송 코드 목록을 포함하는 List */ @ModelAttribute("deliveryCodes") public List deliveryCodes() { // 배송 코드 목록을 생성. List deliveryCodes = new ArrayList(); deliveryCodes.add(new DeliveryCode("FAST", "빠른 배송")); delive..

라디오 버튼 라디오 버튼은 여러 선택지 중에 하나를 선택할 때 사용할 수 있다. 라디오 버튼을 자바 ENUM을 활용해서 개발한다. 상품 종류 도서, 식품, 기타 라디오 버튼으로 하나만 선택할 수 있다. FormItemController - 추가 // @ModelAttribute 어노테이션이 적용된 메서드 // 이 메서드는 "itemTypes"라는 이름으로 모델에 데이터를 추가한다. @ModelAttribute("itemTypes") public ItemType[] itemTypes() { // ItemType 열거형(enum)의 모든 값을 배열로 반환. // ItemType.values() 메서드는 enum에서 정의한 모든 열거 상수를 배열로 제공. return ItemType.values(); } it..

체크 박스 - 멀티 체크 박스를 멀티로 사용해서, 하나 이상을 체크할 수 있도록. 등록 지역 서울, 부산, 제주 체크 박스로 다중 선택할 수 있다. 등록 폼 수정 @GetMapping("/add") public String addForm(Model model) { model.addAttribute("item", new Item()); Map regions = new LinkedHashMap(); // HashMap 쓰면 순서가 보장x regions.put("SEOUL", "서울"); regions.put("BUSAN", "부산"); regions.put("JEJU", "제주"); model.addAttribute("regions", regions); return "form/addForm"; } Map r..