Controller 4

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

ERROR - Ambiguous mapping found. Cannot map ~~

Ambiguous mapping found. Cannot map 'Controller의 이름' bean method Controller에서 @RequestMapping에 이름이 중복되서 나타나는 에러 중복된 @RequestMapping 이름을 변경해주면 해결 @RequestMapping(value = "root.do", method = RequestMethod.POST) @RequestMapping(value = "root.do", method = RequestMethod.POST) -- > @RequestMapping(value = "root.do", method = RequestMethod.POST) @RequestMapping(value = "root/detail.do")

Java/Spring 2021.07.05

[스프링 웹 개발 기초]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

[View 환경설정] view 기본 동작환경

HelloController.java @Controller public class HelloController { @GetMapping("hello") public String hello(Model model) { model.addAttribute("data", "hello!!"); return "hello"; } } resources/templates/hello.html 안녕하세요. 손님 ​ 컨트롤러에서 리턴 값으로 문자를 반환하면 뷰 리졸버( viewResolver )가 화면을 찾아서 처리한다. 스프링 부트 템플릿엔진 기본 viewName 매핑 resources:templates/ +{ViewName}+ .html

Java/Spring 2021.03.24