我使用Spring MVC和我有一个控制器中的下列方法:Spring MVC的:控制器方法不会被调用
@RequestMapping(value = {"/web", "/web/"})
public void redirectToIndexUi(HttpServletRequest request, HttpServletResponse response) {
try {
//some condition
response.sendRedirect(request.getContextPath() + "/ui/index.html");
} catch (IOException ex) {
LOGGER.error("IOException is thrown while trying to redirect to index.html page.", ex);
}
}
当用户进入以下网址http://localhost:8080/myapp/web/ redirectToIndexUi方法被调用,但在这种情况下, http://localhost:8080/myapp/web/index.html不调用redirectToIndexUi方法。可能是什么原因 ?
你真的不会那样做,因为它会导致无尽的重定向循环! –