Spring控制器方法调用两次


问题内容

我正在制作Spring MVC网络应用程序。问题是在单一方法上被调用了两次,我不知道为什么。

@RequestMapping(value="/profile/{id}", method = RequestMethod.GET)
public String displayUserProfile( @PathVariable String id) {

    System.out.println("asdasddsasd");

    return "account/userProfile";

}

我从这种方法中评论了很多行,但仍然无法正常工作。还试图返回其他视图..没有好运。

在控制台中(编写了ulr请求):

/demo/account/profile/f91b3a38-6921-41e0-98b7-58dff5cb1152
asdasddsasd
/demo/account/profile/0
asdasddsasd

在第二次调用tihs方法之后,将转到我的观点

任何其他方法都可以。有人知道这是什么问题吗?

*我也从这里读过类似的问题..没有任何帮助

LE:我在评论中也说过。有趣的是,如果我在视图的第二个调用中将模型设置为视图,则我的视图将是第一个调用的模型。(在第二次调用中,ID为0,模型为空)


问题答案:

我终于有时间在这里找到解决方案。尝试了很多事情,但是没有成功。

我用@RequestParam替换了@PathVariable,并且两次都无法访问该URL :)