diminuta
diminuta

Reputation: 1583

Redirect to j_spring_security_logout from a Controller

I have a page with a form that has 2 buttons "save" and "close", both call the same method and if I detect that the close button was pressed I should then redirect to Spring Security logout... but when I do that I get a 404 error in tomcat:

Estado HTTP 404 - /SICCO/WEB-INF/jsp/j_spring_security_logout.jsp

type Informe de estado

mensaje /MyWebapp/WEB-INF/jsp/j_spring_security_logout.jsp

descripción El recurso requerido (/MyWebapp/WEB-INF/jsp/j_spring_security_logout.jsp) no está disponible.

the piece of code is:

@RequestMapping("guardar") 
public String guardar(Model model, @ModelAttribute("precol")Precolonoscopia precol, HttpServletRequest request) {

    if (WebUtils.hasSubmitParameter(request, "cerrar")) {
        return "j_spring_security_logout";
    }
        //things...
    return "/other/page";
}

I've also tried with

return "/j_spring_security_logout"

but I got the same error.

I have another jsp that calls directly to Spring Security Logout:

<c:url value="/j_spring_security_logout" var="url" />
<form action="${url}" method="post">
    <button name="cerrar"><s:message code="myapp.cerrar"/></button>
</form>

And this works as expected...

What am I doing wrong?

Upvotes: 1

Views: 4875

Answers (1)

diminuta
diminuta

Reputation: 1583

I've just come up with the solution:

return "redirect:/j_spring_security_logout"

does the trick :)

Upvotes: 2

Related Questions