Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use precise mapping annotation, i.e. '@GetMapping', '@PostMapping', etc

Replace @RequestMapping with specific @GetMapping, @PostMapping etc.

I’m trying to show the jsp page in the browser. So I used @RequestMapping. But it shows warning like Use precise mapping annotation, i.e. '@GetMapping', '@PostMapping', etc.

public class LocationControler 
{
    @RequestMapping("/showCreate")
    public String showCreate()
    {
        return "CreateLocation";
    }
}

CreateLocation will display the jsp file CreateLocation.jsp.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In application.properties I have set like this

spring.mvc.view.prefix=/WEB-INF/jsps/
spring.mvc.view.suffix=.jsp

I tried with @PostMapping
In browser I’m getting this error.
There was an unexpected error (type=Method Not Allowed, status=405).

For this whic method should I use?.

@GetMapping - shortcut for @RequestMapping(method = RequestMethod.GET)
@PostMapping - shortcut for @RequestMapping(method = RequestMethod.POST)
@PutMapping - shortcut for @RequestMapping(method = RequestMethod.PUT)
@DeleteMapping - shortcut for @RequestMapping(method =RequestMethod.DELETE)

>Solution :

Unless you are using specific http method, go with @GetMapping, which will be used by default by your browser. I do recommend to read up about various http methods and their usage though.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading