exception - acess to userName from jsp using spring security -
i want output username if log in. @controller have access:
@requestmapping("/success") public string success(model model) { authentication auth = securitycontextholder.getcontext().getauthentication(); string name = auth.getname(); //get logged in username model.addattribute("name", name); return "success"; }
it work if use name on jsp, see typed name.
but if in jsp write
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <sec:authentication property="principal.username"/>
i stacktrace:
info : com.epam.hhsystem.util.customauthentificationprovider - user name 'nikolay_tkachev' log in 07.08.2013 17:00:57 org.apache.jasper.compiler.tldlocationscache tldscanjar info: @ least 1 jar scanned tlds yet contained no tlds. enable debug logging logger complete list of jars scanned no tlds found in them. skipping unneeded jars during scanning can improve startup time , jsp compilation time. 07.08.2013 17:00:57 org.apache.catalina.core.applicationdispatcher invoke severe: servlet.service() servlet jsp threw exception org.springframework.beans.notreadablepropertyexception: invalid property 'principal.username' of bean class [org.springframework.security.authentication.usernamepasswordauthenticationtoken]: bean property 'principal.username' not readable or has invalid getter method: return type of getter match parameter type of setter? @ org.springframework.beans.beanwrapperimpl.getpropertyvalue(beanwrapperimpl.java:707) @ org.springframework.beans.beanwrapperimpl.getpropertyvalue(beanwrapperimpl.java:699)
...
as have authentiucation using using username , password, principal self name of user. try using
<sec:authentication property="principal"/>
Comments
Post a Comment