结合 Spring Security 标签和 Struts2 标签 [英] Combining Spring Security Tags and Struts2 Tags

查看:54
本文介绍了结合 Spring Security 标签和 Struts2 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 Spring Security 来管理我的 Struts2 应用程序上的登录和会话.为了在 JSP 页面中检索登录用户,我通过将以下内容导入我的 jsp 来使用 sec 标记库.

I'm currently using Spring Security to manage login and sessions on my Struts2 application. To retrieve the logged user in a JSP page I'm using the sec tag lib by importing the following to my jsp.

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

所以要打印我登录的用户,我使用 <sec:authentication property="principal.username"/>.

So to print my logged user i use <sec:authentication property="principal.username" />.

我正在遍历通过调用的操作接收到的 java.util.List,因此遍历如下:

I'm iterating through a java.util.List received through the action called, so a iterate it through something like this:

<s:iterator value="#request.myList" var="userEmail">
    My value: <s:property value="#userEmail"/>
</s:iterator>

我正在寻找一种方法来测试列表项以检查是否与登录用户相同,但我无法在 <s 中检索 sec:if> 标签.

I'm looking for a way to test the list item to check if is the same as the logged user, but I can't manage to retrieve sec inside a <s:if> tag.

有谁知道如何将两者结合起来?并做一些像

Does anyone know how to combine both? and do something like

<s:if test="%{<sec:authentication property="principal.username"/> == #userEmail}">

推荐答案

如何只使用会话中的信息:

How about just using information from session:

<s:if test="#session.SPRING_SECURITY_CONTEXT.authentication.principal.username == #userEmail">

这篇关于结合 Spring Security 标签和 Struts2 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆