개미는뚠뚠/개발자

ResponseEntity 클래스, @PathVariable, @RequestParam

뚠냥e 2021. 3. 23. 17:25
728x90
반응형

-ResponseEntity : ResponseEntity는 HttpEntity를 상속받고, HttpHearder와 body를 가질 수 있다.

 

Ex) public ResponseEntity<HashMap<String, Object>> getTest(final @PathVariable(name ="testNo") int testNo) throws Exception { 

             return ResponseEntity.ok().body(this.TestService.getTest(testNo)); 

 

-@PathVariable : PathVariable은 url에서 구분자에 들어오는 값 처리할 때 사용한다 

testNo를 사용하여 구분함 

 

-@RequestParam : 아래 예시와 같은 경우 no라는 파라미터를 받아오게 된다. 전달인자의 이름을 RequestParam괄호안에 표시하게 된다. read라는 url 뒤에 붙는 파라미터의 값을 가져옴 

@GetMapping("read")
public ModelAndView getFactoryRead(@RequestParam("no") int factroyId, SearchCriteria criteria)
{
//...
}

 

 

반응형