Ich verwende Spring MVC und ich habe eine folgende Methode in der Steuerung:Spring MVC: Controller-Methode wird nicht
@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);
}
}
Wenn ein Benutzer gibt die folgende URL http://localhost:8080/myapp/web/ redirectToIndexUi Methode aufgerufen wird, aber in diesem Fall http://localhost:8080/myapp/web/index.html Die redirectToIndexUi-Methode wird nicht aufgerufen. Was könnte der Grund sein?
Sie werden das wirklich nicht mögen, da dies zu einer endlosen Umleitungsschleife führen würde! –