0
我不知道我的许可检查是否正确,但我是这样做的。struts2,使用静态参数调用会话变量方法
public class User {
public boolean hasPermission (String permission){
// codes here to check from Roles.permissions if permission parameter exists
// return true if exists, otherwise return false
}
}
在我的JSP,我想隐藏一个按钮,如果它被保存在session中“当前用户”的用户不具有“save.settings的许可。
组织我的代码,我宣布一个接口:
public interface Permission {
public static final String SAVE_SETTINGS = "save.settings";
}
使权限检查时,我只是访问我的JSP中的静态变量。
现在我该如何在JSP中执行此操作?我试过...
<s:if test="{#session.currentUser.hasPermission(@[email protected]_SETTINGS)}">
<div>
<input id="iSave" type="button" value="Save" />
</div>
</s:if>
但它没有工作。
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
也在我的struts.xml
任何想法家伙设定?
作为一个全面的检查,如果你使用''查看静态无功,它的工作原理? –