취업 준비

UserController.java package com.pure.blog.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class UserController { @GetMapping("/user/joinForm") public String joinForm() { return "user/joinForm"; } @GetMapping("/user/loginForm") public String loginForm() { return "user/loginForm"; } } joinForm.jsp Username:..
https://www.w3schools.com/bootstrap4/bootstrap_navbar.asp Bootstrap 4 Navigation Bar W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. www.w3schools.com https://www.w3schools.com/bootstrap4/bootstrap_templates.asp Bootstrap 4 Templates W3Schools offe..
1. Get 요청 주소에 데이터를 담아서 보낸다. ==> Http body가 없다. 데이터 형태는 key = value 2. Post, Put, Delete 요청 (데이터를 변경) 담아 보내야 할 데이터가 여러개임. post 방식은 form 태그의 method = 'post'로 하면 됨. 하지만 form태그는 get, post 방식만 사용 가능. 그래서 나머지는 자바스크립트로 요청해야 함. ==> 자바스크립트로 ajax 요청, 형식은 JSON으로 통일하게 됨. *form:form 태그라는 것도 있음. (스프링 프레임워크 기능) taglib 중에 하나임. 3. 스프링 컨트롤러의 파싱 전략 1 key = value 형태는 자동으로 파싱하여 변수에 담아줌. 4. 스프링 컨트롤러의 파싱 전략 2 key = va..
package com.pure.blog.handler; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestController; @ControllerAdvice @RestController public class GlobalExceptionHandler { @ExceptionHandler(value=IllegalArgumentException.class) public String handleArgumentException(IllegalA..
@DeleteMapping("/dummy/user/{id}") public String delete(@PathVariable int id) { try { userRepository.deleteById(id); } catch(EmptyResultDataAccessException e) { return "삭제에 실패하였습니다. 해당 id는 DB에 없습니다."; } return "삭제되었습니다. id: " + id; } 삭제는 별 거 없다. 이런식으로 예외 처리 정도만 해주면 된다.
@GetMapping("/dummy/users") public List list() { return userRepository.findAll(); } //한 페이지당 2건에 데이터를 리턴받기 (size=2) @GetMapping("/dummy/user") public List pageList(@PageableDefault(size=2, sort="id", direction = Sort.Direction.DESC) Pageable pageable) { Page pagingUser = userRepository.findAll(pageable); List users = pagingUser.getContent(); return users; } 계속 이어서 Dummy 컨트롤러임. findAll()은 전체 리스트를..
package com.pure.blog.test; import java.util.function.Supplier; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import com.pure.blog.model.R..
1. User.java 에 @DynamicInsert 추가 package com.pure.blog.model; import java.sql.Timestamp; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations..
Purewater
'취업 준비' 카테고리의 글 목록 (7 Page)