Spring Annotation Tutorial - @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping

preview_player
Показать описание
#Alternative #of #RequestMapping #Annotation

Instagram: techtalk_debu

if you like my video, please subscribe to my channel and share the video

@RequestMapping(method = RequestMethod.GET) equivalent @GetMapping :- HTTP specific Method

@RequestMapping(method = RequestMethod.POST) equivalent @PostMapping :- HTTP specific Method

@RequestMapping(method = RequestMethod.PUT) equivalent @PutMapping :- HTTP specific Method

@RequestMapping(method = RequestMethod.DELETE) equivalent @DeleteMapping :- HTTP specific Method

@RequestMapping(method = RequestMethod.PATCH) equivalent @PatchMapping :- HTTP specific Method

@RequestMapping(method = RequestMethod.HEAD) equivalent @HeadMapping :- HTTP specific Method

In Class level mapping we need @RequestMapping : below example

@Controller
@RequestMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public class HomeController
{
@PostMapping(path = "/members")
//code
}

@PostMapping(path = "/members", produces = MediaType.APPLICATION_XML_VALUE)
//code
}
}

Thanks & Regards,
Debu Paul
Рекомендации по теме
Комментарии
Автор

Is that E-Commerce project available on your channel??

codegeek
Автор

Hello. In your repository *Spring-webclient-resttemplate*, you are accessing response body through restTemplate.exchange(). And then mapping an Object Customer with response.body().

Can I do the same without using restTemplate.postForObject() or restTemplate.exchange(). Only with annotations like @GetMapping? Receive a response and map it's body to Object. For example:
User user = new

I don't want to access Controller @Bean directly in the same class.

MrDSLow
Автор

My RequestMapping method type is GET but still it's accessable with HEAD how to avoid it.
I just want to access the method if the request type is only GET

Thanks in advance, waiting for your reply

satheeshkumarreddy
Автор

sir, i have a question about @GetMapping.
when i create some method in RestController, using @GetMapping, I want to write it considering utf-8.
But i can't find a way to setting @GetMapping or @PathVariable parameter by utf-8
How can i fix it?

I tried add "<Connector port="8080" ... URIEncoding="UTF-8" />" in tomcat/.../server.xml, But it doesn't work.

My development environment is,
#SpringBoot, #JPA/Hibernate, #gradleProject.

Please help me sir.

ahndding