작성자 없음
작성자 정보가 삭제된 글입니다.
작성
·
193
0
package mvcStructure.basic.request;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Slf4j
@Controller
public class RequestParamController {
@RequestMapping("/request-param-v1")
public void requestParamV1(HttpServletRequest request, HttpServletResponse response) throws IOException {
String username = request.getParameter("username");
int age = Integer.parseInt(request.getParameter("age"));
response.getWriter().write("ok");
}
@ResponseBody
@RequestMapping("/request-param-v3")
public String requestParamV3(@RequestParam String username,
@RequestParam String age){
log.info("username = {}, age = {}", username, age);
return "ok";
}
//@RequestParam 생략하고 단순 타입이면 자동으로 RequestParam이라고 요청 파라미터라고 인식한다
@ResponseBody
@RequestMapping("/request-param-v4")
public String requestParamV34( String username, String age){
log.info("username = {}, age = {}", username, age);
return "ok";
}
@ResponseBody
@RequestMapping("/request-param-Required")
public String requestParamRequired(
@RequestParam(required = true) String username,
@RequestParam(required = false) Integer age){
log.info("username = {}, age = {}", username, age);
return "ok";
}
}
현재소스이고 경로는 아래와 같이 했습닌다
===========================================
properties속성은 아래와 같습니다
============================
#mvcStructure.~~ 패키지와 그 하위 로그레벨 설정
logging.level.root=info
logging.level.hello.springmvc=debug
==============================
현재 접속하면 whitepage가 나는건 왜그런가요