GrailsSpring安全用户名全局
我正在学习Spring Security的来龙去脉…进展缓慢 现在我正在尝试从index.gsp页面访问当前登录的用户用户名。我有可以从控制器工作的代码,但我无法为任何其他页面获得正确的代码。我有一种感觉,我丢失了一些与用户对象相关的关键信息 以下是我对控制器的使用:GrailsSpring安全用户名全局,grails,spring-security,Grails,Spring Security,我正在学习Spring Security的来龙去脉…进展缓慢 现在我正在尝试从index.gsp页面访问当前登录的用户用户名。我有可以从控制器工作的代码,但我无法为任何其他页面获得正确的代码。我有一种感觉,我丢失了一些与用户对象相关的关键信息 以下是我对控制器的使用: class BookController { def springSecurityService static allowedMethods = [save: "POST", update: "POST", d
class BookController {
def springSecurityService
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
def index() {
redirect(action: "list", params: params)
}
def list(Integer max) {
def userDetails = springSecurityService.principal
params.max = Math.min(max ?: 10, 100)
[bookInstanceList: Book.list(params), bookInstanceTotal: Book.count(), muds: userDetails]
}
...
... etc
...
然后在视图(gsp)中,我可以简单地执行以下操作:
Username: ${muds.getUsername() }
如何在index.gsp中执行此操作?您最好使用插件附带的内置标记库。显示所有各种标记,其中一个用于获取当前登录用户的属性。例如:
<sec:loggedInUserInfo field="username"/>
您最好使用插件附带的内置标记库。显示所有各种标记,其中一个用于获取当前登录用户的属性。例如:
<sec:loggedInUserInfo field="username"/>
您在${muds.getUsername()}中是否有任何错误?尝试只使用${muds},或者最好检查${muds}类${muds.getUsername()}是否有任何错误?尝试只使用${muds}或者最好检查${muds}类我是否需要为taglib添加其他插件?我得到了这个错误:处理GroovyPageView时出错:未知JSP标记sec:loggedInUserInfoNo。您使用的是哪个版本的spring security core插件?spring security core:1.2.7.3尝试执行grails clean我经常执行clean…仍然不工作。在我的GSP顶部有:Ec lipse IDE说:“找不到的标记库描述符”“taglib是否需要其他插件?我得到了这个错误:处理GroovyPageView时出错:未知JSP标记sec:loggedInUserInfoNo。您使用的是哪个版本的spring security core插件?spring security core:1.2.7.3尝试执行grails clean我经常执行clean…仍然不工作。在我的GSP顶部有:Ec lipse IDE说:“找不到的标记库描述符”