英文:
How to prevent apache server to be hitting twice on a java get request
问题
我正在使用一个apache tomcat服务器
,在进行项目时,我所有的GET请求方法都会被调用两次,而不需要手动发起调用。如果我调用一个方法,在其返回后,该方法会自动被再次调用。我已经尝试了许多方法,但都没有帮助。这个项目与另一个正常工作的项目是完全相同的副本,然而旧项目运行良好。
我尝试了以下几种策略,但都没有解决我的问题:
-
https://www.niceonecode.com/Question/20307/MVC-Controller-Action-Gets-Called-Multiple-Times
-
https://stackoverflow.com/questions/36325529/spring-controller-method-called-twice/36679031#36679031
我还验证了是否有任何脚本发起了第二次调用,但没有这样的脚本。
有谁能帮助我解决这个问题吗?
我的方法的示例代码:
@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";
}
英文:
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
-
https://www.niceonecode.com/Question/20307/MVC-Controller-Action-Gets-Called-Multiple-Times
-
https://stackoverflow.com/questions/36325529/spring-controller-method-called-twice/36679031#36679031
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";
}
答案1
得分: 1
我遇到了同样的问题。然后我在我的index.html
文件中将href="Favicon.ico"
更改为空。然后它起效了。将它改为href=""
。
英文:
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=""
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论