1

I'm using an apache tomcat server, on doing a project all my get request methods are hitting twice without initiating the call manually. If i call a method, on its return the method is being called again automatically. I have tried many ways but it doesn't helps me. This project is a same copy of another working project, however the old project is working fine.

I have tried these following answers, but this couldn't solve my problem

  1. https://www.niceonecode.com/Question/20307/MVC-Controller-Action-Gets-Called-Multiple-Times

  2. Spring controller method called twice

I have also verified if any of my scripts is initiating the second call, but there is no scripts like that. Can anyone helps me out?

Sample code of my method

@RequestMapping(value = "/method/test/{id}/{name}", method = RequestMethod.GET) public String getTestMethod(@PathVariable int id, @PathVariable String name, Model model, HttpServletRequest request, HttpServletResponse response, RedirectAttributes ra) { System.out.println("success"); return "success"; }

Sonu
  • 179
  • 1
  • 11
  • are you sure it's calling GET, not OPTIONS then GET? - assuming "scripts" means javascript in a HTML page – Jaromanda X May 04 '20 at 08:39
  • @JaromandaX Thank you for your valuable time. I have updated my question with example of the java method i'm using. It s page load and not an ajax call through script. – Sonu May 04 '20 at 09:08
  • Oh, right, so there's no javascript at all - no ... that's the server, right? so the client is making the two calls, so what is the client getting as a response in the two calls it makes? – Jaromanda X May 04 '20 at 11:57

1 Answers1

1

I had the same problem. Then I have changed href="Favicon.ico" to empty in my index.html file. Then it worked. Change it to href="".

Pedro Mutter
  • 1,178
  • 1
  • 13
  • 18
Fredo MG
  • 26
  • 1