requestparam 3

Controller parameter 받는 방법

Controller은 비지니스 로직을 처리하고 데이터를 가공 하는 역할을 하는데, 이때 비지니스 로직을 처리하기위해 controller에서 데이터를 받는 방법 HttpServletRequest @RequestParam @RequestBody @ModelAtrribute @PathVariable localhost:8082/test?id=test localhost:8082/test?searchType=all&keyword=er 1. HttpServletRequest.getParameter() - 클라이언트의 요청정보를 확인하게해주는 HttpServletRequest를 이용하기 @GetMapping("/test"); public void getInfo(HttpServletRequest request){ log..

Java/Spring 2022.04.09

@RequestParam, 커맨드객체

private ModelAndView request_TEST(@RequestParam("test") int num, @RequestParam("test2") String str)){ //.. } 위처럼 하나이상의 타입을 적용가능. 스프링에서 지원하는 변환기에서 지원되는 모든 타입을 변환가능 RequestParam은 하나 이상의 파라미터 사용가능 ReqeustParam에 넘어오는 데이터가 존재하지 않는다면 BadRequest 400번대 error가 발생함. private ModelAndView request_TEST(@RequestParam(value="test", required=false, defaultValue= "0") int num, @RequestParam("test2") String str))..

Java/Spring 2021.03.24

[스프링 웹 개발 기초]MVC와 템플릿 엔진

MVC: Model, View, Controller Controller @Controller public class HelloController { @GetMapping("hello-mvc") public String helloMvc(@RequestParam("name") String name, Model model) { model.addAttribute("name", name); return "hello-template"; } } View resources/template/hello-template.html hello! empty 실행 http://localhost:8080/hello-mvc?name=spring thymeleaf를 기능 서버 연결없이 html을 실행(절대경로로)하면 hello! emp..

Java/Spring 2021.03.24
1