Issue
I'm making a Spring MVC web app. The problem is that on single method is called twice and I don't know why.
@RequestMapping(value="/profile/{id}", method = RequestMethod.GET)
public String displayUserProfile( @PathVariable String id) {
System.out.println("asdasddsasd");
return "account/userProfile";
}
I commented many line from this method, but is still not working. Also tried to return other view..no good luck.
In console(ulr requests are written):
/demo/account/profile/f91b3a38-6921-41e0-98b7-58dff5cb1152
asdasddsasd
/demo/account/profile/0
asdasddsasd
After the second call of tihs method, it's going to my view
Any other method work fine. Does anyone know what's the problem here?
*I also read similar question from here..nothing helped
LE: what I also said in the comments. What is funny is that, if I set o model to the view, on the second call of the method, my view get's the model from the first call. (on the second call, with id 0, the model is null)
Solution
I finally got some time to find a solution here. Tried many things, but it didn't worked.
I replaced @PathVariable with @RequestParam and the URL is not accessed twice :)
Answered By - UnguruBulan
Answer Checked By - Candace Johnson (JavaFixing Volunteer)