-1

彼がログインした場合、userNameを出力したい.@Controllerから私はアクセスできる:

@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";
    }

jspで名前を使用すると機能します。入力された名前が表示されます。

しかし、このjspで私が書いた場合

 <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
    <sec:authentication property="principal.username"/>

私はスタックトレースを取得します:

 INFO : com.epam.hhsystem.util.CustomAuthentificationProvider - User with name 'Nikolay_Tkachev' log in
07.08.2013 17:00:57 org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
07.08.2013 17:00:57 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.springframework.beans.NotReadablePropertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authentication.UsernamePasswordAuthenticationToken]: Bean property 'principal.username' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:707)
    at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:699)

...

4

1 に答える 1