inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

HTTP 요청 파라미터 - @RequestParam

whitepage에러 질문드립니다

242

작성자 없음

작성한 질문수 0

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가 나는건 왜그런가요

springmvc MVC spring

답변 1

0

OMG

안녕하세요. kcj3054@naver.com님, 공식 서포터즈 OMG입니다.

말씀하신 Whitepage에러가 발생하는 브라우저 화면과 접속 시도시 발생하는 콘솔 출력 내용을 하단 답변이나 댓글에 첨부해주세요

감사합니다

servlet과 container에 대한 질문입니다

0

25

1

api를 어느 컨트롤러에 작성해야하는지는 어떤 기준으로 해야하나요?

0

64

1

jsp 의존성 수정 요청

0

80

2

요즘 웹 서버가 주로 사용되는 이유는 SPA 구조 때문일까요 ?

0

143

1

save() 메서드 문의

0

67

1

절대 경로로 templates/basic 하위 파일 열면 css 적용 안되는 현상

0

101

1

request-body-json

0

83

2

MVC 패턴의 적용 단위

0

97

1

RequestMapping을 이용한 핸들러, 어댑터

0

119

2

save 후 결과화면

0

89

2

jsp를 이용한 view

0

97

1

application.properties에 debug 추가해도 결과가 똑같습니다.

0

178

1

수업 코드 제공 관련 문의

0

97

2

RequestMappingHandlerAdapter의 Controller 호출 과정

0

100

3

파일 오픈 시

0

70

1

스프링 배치 관련

0

78

1

@RequestParam의 defaultValue가 blank 값도 처리하는 지 여부

0

112

1

postman으로 /request-body-json-v1 호출시 500 error

0

96

1

프론트엔드와 백엔드의 mvc, rest api에 대한 질문

0

79

1

모델의 역할과 계층 분리에 대한 이해 차이 + 추가질문

0

111

1

console log 출력 관련 질문입니다.

0

75

1

애플리케이션이 실행 되지 않습니다 ㅠㅠㅠ

0

139

1

html 변경하는 부분 적용 문제

0

103

1

한글 깨짐

0

77

2