Home Sprint Boot Controller method called twice
Reply: 0

Sprint Boot Controller method called twice

user2987 Published in July 17, 2018, 7:58 am

I don't know what's wrong with my code, my rest service getting called twice.

Annotations in my controller class

@ComponentScan(basePackages = "com.test.java")

Here is my sample code:

Rest Service:

 @RequestMapping(value="/user", method = RequestMethod.GET)
    public String getUserDetails(ModelMap model, @RequestParam(value = "userId") String userId){
        return "content_home";





I deployed this war file in tomcat8.5 server.

I tried below and all cases service is getting called twice

  1. Tried to hit the rest service from IE, Chrome, Mozilla, Postman
  2. I commented @ComponentScan(basePackages = "com.test.java") as my myappname-servlet.xml is doing a component scan but no luck.
  3. I tried with @ResponseBody in front of the return type of method - Actually this way it's getting called only once but I need to return a jsp not the body. So it won't work out.
  4. I verified network tab in developer tools, request is placed twice as below 1st. Type = Document, Initiator = other 2nd. Type= text/html, Initiator = resturl

Any suggestion or help is greatly appreciated. Thank you!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.533255 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO