07.08.2013, 18:24. Показов 2927. Ответов 0
Я хочу на страничке выводить имя пользователя, если он залогинился.
пишу так:
| HTML5 |
1
2
| <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authentication property="principal.username"/> |
|
получаю:
INFO : com.epam.hhsystem.util.CustomAuthentific ationProvider - User with name 'Nikolay_Tkachev' log in
07.08.2013 17:00:57 org.apache.jasper.compiler.TldLocationsC ache 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.ApplicationDisp atcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.springframework.beans.NotReadablePro pertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authenticat ion.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.BeanWrapperImp l.getPropertyValue(BeanWrapperImpl.java: 707)
at org.springframework.beans.BeanWrapperImp l.getPropertyValue(BeanWrapperImpl.java: 699)
at org.springframework.security.taglibs.aut hz.AuthenticationTag.doEndTag(Authentica tionTag.java:101)
at org.apache.jsp.WEB_002dINF.views.success _jsp._jspx_meth_sec_005fauthentication_0 05f0(success_jsp.java:96)
at org.apache.jsp.WEB_002dINF.views.success _jsp._jspService(success_jsp.java:68)
at org.apache.jasper.runtime.HttpJspBase.se rvice(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrap per.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.ser viceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.ser vice(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilt erChain.internalDoFilter(ApplicationFilt erChain.java:305)
at org.apache.catalina.core.ApplicationFilt erChain.doFilter(ApplicationFilterChain. java:210)
at org.apache.catalina.core.ApplicationDisp atcher.invoke(ApplicationDispatcher.java :749)
at org.apache.catalina.core.ApplicationDisp atcher.processRequest(ApplicationDispatc her.java:487)
at org.apache.catalina.core.ApplicationDisp atcher.doForward(ApplicationDispatcher.j ava:412)
at org.apache.catalina.core.ApplicationDisp atcher.forward(ApplicationDispatcher.jav a:339)
at org.springframework.web.servlet.view.Int ernalResourceView.renderMergedOutputMode l(InternalResourceView.java:238)
at org.springframework.web.servlet.view.Abs tractView.render(AbstractView.java:263)
at org.springframework.web.servlet.Dispatch erServlet.render(DispatcherServlet.java: 1208)
at org.springframework.web.servlet.Dispatch erServlet.processDispatchResult(Dispatch erServlet.java:992)
at org.springframework.web.servlet.Dispatch erServlet.doDispatch(DispatcherServlet.j ava:939)
at org.springframework.web.servlet.Dispatch erServlet.doService(DispatcherServlet.ja va:856)
at org.springframework.web.servlet.Framewor kServlet.processRequest(FrameworkServlet .java:936)
at org.springframework.web.servlet.Framewor kServlet.doGet(FrameworkServlet.java:827 )
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:621)
at org.springframework.web.servlet.Framewor kServlet.service(FrameworkServlet.java:8 12)
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilt erChain.internalDoFilter(ApplicationFilt erChain.java:305)
at org.apache.catalina.core.ApplicationFilt erChain.doFilter(ApplicationFilterChain. java:210)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:330)
at org.springframework.security.web.access. intercept.FilterSecurityInterceptor.invo ke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access. intercept.FilterSecurityInterceptor.doFi lter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.access. ExceptionTranslationFilter.doFilter(Exce ptionTranslationFilter.java:113)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.session .SessionManagementFilter.doFilter(Sessio nManagementFilter.java:103)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.authent ication.AnonymousAuthenticationFilter.do Filter(AnonymousAuthenticationFilter.jav a:113)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.servlet api.SecurityContextHolderAwareRequestFil ter.doFilter(SecurityContextHolderAwareR equestFilter.java:54)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.savedre quest.RequestCacheAwareFilter.doFilter(R equestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.authent ication.AbstractAuthenticationProcessing Filter.doFilter(AbstractAuthenticationPr ocessingFilter.java:183)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.authent ication.logout.LogoutFilter.doFilter(Log outFilter.java:105)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.context .SecurityContextPersistenceFilter.doFilt er(SecurityContextPersistenceFilter.java :87)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.FilterC hainProxy.doFilterInternal(FilterChainPr oxy.java:192)
at org.springframework.security.web.FilterC hainProxy.doFilter(FilterChainProxy.java :160)
at org.springframework.web.filter.Delegatin gFilterProxy.invokeDelegate(DelegatingFi lterProxy.java:346)
at org.springframework.web.filter.Delegatin gFilterProxy.doFilter(DelegatingFilterPr oxy.java:259)
at org.apache.catalina.core.ApplicationFilt erChain.internalDoFilter(ApplicationFilt erChain.java:243)
at org.apache.catalina.core.ApplicationFilt erChain.doFilter(ApplicationFilterChain. java:210)
at org.apache.catalina.core.StandardWrapper Valve.invoke(StandardWrapperValve.java:2 22)
at org.apache.catalina.core.StandardContext Valve.invoke(StandardContextValve.java:1 23)
at org.apache.catalina.authenticator.Authen ticatorBase.invoke(AuthenticatorBase.jav a:472)
at org.apache.catalina.core.StandardHostVal ve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportVa lve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValv e.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineV alve.invoke(StandardEngineValve.java:118 )
at org.apache.catalina.connector.CoyoteAdap ter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11P rocessor.process(AbstractHttp11Processor .java:1009)
at org.apache.coyote.AbstractProtocol$Abstr actConnectionHandler.process(AbstractPro tocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$S ocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$ Worker.runTask(ThreadPoolExecutor.java:8 86)
at java.util.concurrent.ThreadPoolExecutor$ Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
07.08.2013 17:00:57 org.apache.catalina.core.StandardWrapper Valve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/ui] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspException: org.springframework.beans.NotReadablePro pertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authenticat ion.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?] with root cause
org.springframework.beans.NotReadablePro pertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authenticat ion.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.BeanWrapperImp l.getPropertyValue(BeanWrapperImpl.java: 707)
at org.springframework.beans.BeanWrapperImp l.getPropertyValue(BeanWrapperImpl.java: 699)
at org.springframework.security.taglibs.aut hz.AuthenticationTag.doEndTag(Authentica tionTag.java:101)
at org.apache.jsp.WEB_002dINF.views.success _jsp._jspx_meth_sec_005fauthentication_0 05f0(success_jsp.java:96)
at org.apache.jsp.WEB_002dINF.views.success _jsp._jspService(success_jsp.java:68)
at org.apache.jasper.runtime.HttpJspBase.se rvice(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrap per.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.ser viceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.ser vice(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilt erChain.internalDoFilter(ApplicationFilt erChain.java:305)
at org.apache.catalina.core.ApplicationFilt erChain.doFilter(ApplicationFilterChain. java:210)
at org.apache.catalina.core.ApplicationDisp atcher.invoke(ApplicationDispatcher.java :749)
at org.apache.catalina.core.ApplicationDisp atcher.processRequest(ApplicationDispatc her.java:487)
at org.apache.catalina.core.ApplicationDisp atcher.doForward(ApplicationDispatcher.j ava:412)
at org.apache.catalina.core.ApplicationDisp atcher.forward(ApplicationDispatcher.jav a:339)
at org.springframework.web.servlet.view.Int ernalResourceView.renderMergedOutputMode l(InternalResourceView.java:238)
at org.springframework.web.servlet.view.Abs tractView.render(AbstractView.java:263)
at org.springframework.web.servlet.Dispatch erServlet.render(DispatcherServlet.java: 1208)
at org.springframework.web.servlet.Dispatch erServlet.processDispatchResult(Dispatch erServlet.java:992)
at org.springframework.web.servlet.Dispatch erServlet.doDispatch(DispatcherServlet.j ava:939)
at org.springframework.web.servlet.Dispatch erServlet.doService(DispatcherServlet.ja va:856)
at org.springframework.web.servlet.Framewor kServlet.processRequest(FrameworkServlet .java:936)
at org.springframework.web.servlet.Framewor kServlet.doGet(FrameworkServlet.java:827 )
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:621)
at org.springframework.web.servlet.Framewor kServlet.service(FrameworkServlet.java:8 12)
at javax.servlet.http.HttpServlet.service(H ttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilt erChain.internalDoFilter(ApplicationFilt erChain.java:305)
at org.apache.catalina.core.ApplicationFilt erChain.doFilter(ApplicationFilterChain. java:210)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:330)
at org.springframework.security.web.access. intercept.FilterSecurityInterceptor.invo ke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access. intercept.FilterSecurityInterceptor.doFi lter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.access. ExceptionTranslationFilter.doFilter(Exce ptionTranslationFilter.java:113)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.session .SessionManagementFilter.doFilter(Sessio nManagementFilter.java:103)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.authent ication.AnonymousAuthenticationFilter.do Filter(AnonymousAuthenticationFilter.jav a:113)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.servlet api.SecurityContextHolderAwareRequestFil ter.doFilter(SecurityContextHolderAwareR equestFilter.java:54)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.savedre quest.RequestCacheAwareFilter.doFilter(R equestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.authent ication.AbstractAuthenticationProcessing Filter.doFilter(AbstractAuthenticationPr ocessingFilter.java:183)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.authent ication.logout.LogoutFilter.doFilter(Log outFilter.java:105)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.context .SecurityContextPersistenceFilter.doFilt er(SecurityContextPersistenceFilter.java :87)
at org.springframework.security.web.FilterC hainProxy$VirtualFilterChain.doFilter(Fi lterChainProxy.java:342)
at org.springframework.security.web.FilterC hainProxy.doFilterInternal(FilterChainPr oxy.java:192)
at org.springframework.security.web.FilterC hainProxy.doFilter(FilterChainProxy.java :160)
at org.springframework.web.filter.Delegatin gFilterProxy.invokeDelegate(DelegatingFi lterProxy.java:346)
at org.springframework.web.filter.Delegatin gFilterProxy.doFilter(DelegatingFilterPr oxy.java:259)
at org.apache.catalina.core.ApplicationFilt erChain.internalDoFilter(ApplicationFilt erChain.java:243)
at org.apache.catalina.core.ApplicationFilt erChain.doFilter(ApplicationFilterChain. java:210)
at org.apache.catalina.core.StandardWrapper Valve.invoke(StandardWrapperValve.java:2 22)
at org.apache.catalina.core.StandardContext Valve.invoke(StandardContextValve.java:1 23)
at org.apache.catalina.authenticator.Authen ticatorBase.invoke(AuthenticatorBase.jav a:472)
at org.apache.catalina.core.StandardHostVal ve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportVa lve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValv e.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineV alve.invoke(StandardEngineValve.java:118 )
at org.apache.catalina.connector.CoyoteAdap ter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11P rocessor.process(AbstractHttp11Processor .java:1009)
at org.apache.coyote.AbstractProtocol$Abstr actConnectionHandler.process(AbstractPro tocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$S ocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$ Worker.runTask(ThreadPoolExecutor.java:8 86)
at java.util.concurrent.ThreadPoolExecutor$ Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
|
а если так
| Java |
1
2
3
4
5
6
7
| @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";
} |
|
и так
то работает
Как обратиться на страничке к имени?
Добавлено через 47 минут
от балды попробовал
| Java |
1
2
| <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authentication property="principal"/> |
|
и заработало - странно очень