HTML
<div ng-model="currentUser" id="userContainer">{{currentUser.email}}
<div class="dropdown-content">
<a href="/logout">Logout</a>
</div>
</div>
Controller
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public void logout(HttpServletResponse response, HttpServletRequest request) throws Exception {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
cookie.setValue("");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
response.sendRedirect("/index.html");
}
I am running a Spring boot application and have defined the logout controller as a GET method.
When clicking the Logout Div, the url changes to http://******.ngrok.io/logout
but it never hits the Controller method, but when I reload the browser with http://******.ngrok.io/logout
URL then the controller gets hit and logs me out of application.
<a href> not hitting get method in Spring boot