Method Difference with Getmapping and Requestmapping

Asked

Viewed 3,340 times

1

Good morning guys. What’s the difference between the methods below and what should I be following in developing Java Web applications

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • Josemar, you better put the code in place of the code image

  • Thanks for the tip, but I thought it was best to leave the image. But thanks for the tip. It seems to be more visible but all right and thanks.

1 answer

2


Short answer

There is no difference in semantics

Specifically, @Getmapping a compound notation that acts as a shortcut to @Requestmapping (method = Requestmethod.GET).

Additional reading:

RequestMapping can be used at class level:

This annotation can be used both in the class and at the method level. In most cases, at the method level, applications will prefer to use one of the specific variants of the HTTP @Getmapping, @Postmapping, @Putmapping, @Deletemapping or @Patchmapping method.

while GetMapping only applies to the method:

Notation for mapping HTTP GET requests into specific manipulative methods.

Reading documentation:

Getmapping

Requestmapping

  • Thank you. It was very clear the difference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.