서버 16

#자바에서 JSON형식 사용하기

자바에서 JSON을 사용하기 위해서는 JSONObject, JSONArray 클래스가 필요하다 https://mvnrepository.com/에서 필요한 라이브러리를 임포트할 수 있다. JSON을 검색하고 JAVA에서 사용이 가장 많은 라이브러리를 찾는다. Gradle의 경우 아래와 같이 해당 내용을 복사해서 build.gradle>dependencies에 추가하고 Run을 한다. 우측 Gradle에서 새로고침을 한다. 실제 필요한 데이터를 추출하는 과정은 다음과 같다. public static void main(String[] args) { NaverShopSearch naverShopSearch = new NaverShopSearch(); String result = naverShopSearch.se..

서버/Spring boot 2022.01.25

#ARC를 통해 Java로 Open API가져오기

ARC를 통해 Open API를 가져오기 전에 테스트를 해볼 수 있다. 문서를 참고해서 다음과 같이 실행할 수 있다. 문서에서 알려준대로 요청방식은 GET + 필수정보(query) + Header에 다음 내용을 넣으면 된다. 또한 해당 내용을 원하는 Language + platform으로 가져올 수 있다. 그리고 해당 내용을 원하는 class에 메소드를 만들어 입력해주면 된다. public class NaverShopSearch { //검색어 query를 입력하면 해당 키워드로 검색 public String search(String query){ //ARC에서 복사해본 부분 RestTemplate rest = new RestTemplate(); HttpHeaders headers = new HttpHea..

서버/Spring boot 2022.01.25

#HiddenHttpMethodFilter

HTML은 POST, GET 방식의 요청만 지원 Spring은 POST, GET 방식을 이용해 PUT과 DELETE 방식을 사용할 수 있는 기능을 지원 설정 application.properties spring.mvc.hiddenmethod.filter.enabled=true​ 사용 방법 //게시글 삭제하기 @DeleteMapping("/post/{id}") public String delete(@PathVariable("id") Long id) { boardService.deletePost(id); return "redirect:/"; } 삭제 참고문헌: https://earth-95.tistory.com/49

서버/Spring boot 2022.01.24

#IntelliJ에서 Spring Boot Devtools 사용하기

Spring Boot Devtools를 사용하면 소스 변경이 발생할 때마다 빠르게 자동 빌드를 해주어 바로바로 반영 결과를 확인할 수 있다. 설정 dependency에 추가 build.gradle dependencies { developmentOnly 'org.springframework.boot:spring-boot-devtools' }​ File > Setting > Build, Exeution, Deployment > Compiler > Build project automatically 체크 File > Setting > Advanced Setting > Allow auto-make to start even if developed application is currently running 체크 참고..

서버/Spring boot 2022.01.24

#Thymeleaf

타임리프는 텍스트, html, xml, js, css를 생성할 수 있는 템플릿 엔진이다. 순수 HTML로 템플릿을 작성할 수 있다. Springboot에서 사용이 권장되고 있다.(Springboot에서는 JSP를 추천하지 않음!) 설정 프로젝트 시작시 dependencies에 Thymeleaf를 추가해준다. build.gradle dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'​ Controller는 @Controller 어노테이션을 부여한다(@RestController시 사용불가) 기본경로는 templates이다. html확장자는 생략해도 된다. 참고자료 : https://byeong9935.ti..

서버/Spring boot 2022.01.24