Spring mvc Spring控制器在非私有浏览时调用了两次
我遇到了一个奇怪的问题,我的spring控制器因为一个请求被调用了两次,但是当我的firefox变成私人浏览时,这个问题就消失了 控制器是:Spring mvc Spring控制器在非私有浏览时调用了两次,spring-mvc,Spring Mvc,我遇到了一个奇怪的问题,我的spring控制器因为一个请求被调用了两次,但是当我的firefox变成私人浏览时,这个问题就消失了 控制器是: @Controller @RequestMapping("/user/*") public class UserController { @RequestMapping(method=RequestMethod.GET, value="home") public String home(Model model, NativeWebRequest re
@Controller
@RequestMapping("/user/*")
public class UserController {
@RequestMapping(method=RequestMethod.GET, value="home")
public String home(Model model, NativeWebRequest request, HttpSession session) {
return "user/homepage";
}
}
注意:我已经验证了user/homePage.jsp,它没有任何引用空值的静态资源(而且这个问题只发生在非私有浏览上)
提前感谢您的及时帮助您可以检查扫描控制器组件的应用程序上下文是否加载了两次。例如,在web xml中,您将dispatcher servlet配置为web.xml中的dispatcher,并将contextConfigLocation配置为加载以下bean配置文件
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:dispatcher-servlet.xml</param-value>
</context-param>
上下文配置位置
classpath*:dispatcher-servlet.xml
这可能会导致控制器在每个请求中被击中两次,因为dispatcher servlet在dispatcher servlet启动时自动加载一次,在ContextLoaderListener启动时自动加载一次。感谢快速响应:这是我的web.xml:感谢快速响应:我想web.xml看起来不错,如果需要任何更改,请告诉我:contextConfigLocation类路径:spring-config.xml spring org.springframework.web.servlet.DispatcherServlet 1但当我将浏览器置于私人浏览模式时,问题如何得到解决?我不知道;也不要使用任何Cookie嘿,谢谢,1将启动时的加载设置为0解决了问题,但仍然不理解为什么在私下浏览时不会发生此问题