java - use jstl with spring security -
i totally new java ee (spring, jstl, ...). managing make login page spring 4 , jstl denied page 403 failed show due parsing error. don't know reason why unable parse jstl tag, remove , works properly, of course, can not object model , show value.
thanh nhut
error :
whitelabel error page application has no explicit mapping /error, seeing fallback. sun nov 06 14:23:20 ict 2016 there unexpected error (type=internal server error, status=500). exception parsing document: template="403", line 1 - column 18
controller :
public class logincontroller { @getmapping("/") public string index() { return "welcome home page!"; } @requestmapping(value = "/403", method = requestmethod.get) public modelandview accesssdenied() { modelandview model = new modelandview(); //check if user login authentication auth = securitycontextholder.getcontext().getauthentication(); if (!(auth instanceof anonymousauthenticationtoken)) { userdetails userdetail = (userdetails) auth.getprincipal(); system.out.println(userdetail); model.addobject("username", userdetail.getusername()); } model.setviewname("403"); return model; } }
templates/403.jsp :
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <html> <body> <h1>http status 403 - access denied</h1> <c:choose> <c:when test="${empty username}"> <h2>you not have permission access page!</h2> </c:when> <c:otherwise> <h2>username : ${username} <br/>you not have permission access page!</h2> </c:otherwise> </c:choose> </body> </html>
Comments
Post a Comment