OA 权限控制
对于加入删除 初始化password等操作的权限 控制
第一种方法就是在每一个超链接前加 推断 如
<s:if test="#session.user.hasPrivilegeByName(name)">
<td><s:a action="department_delete? id=%{id}&parentId=%{parent.id}" onClick="return window.confirm('这将删除全部的下级部门,您确定要删除吗?')">删除</s:a>
<s:a action="department_editUI?id=%{id}">改动</s:a>
</td>
这样的方法须要在每一个a 标签前加推断 太过麻烦
另一种就是通过改动struts2 <a/>标签的源代码实现 首先在/META-INF/struts-tags.tld文件里找到a 标签
<name>a</name>
<tag-class>org.apache.struts2.views.jsp.ui.AnchorTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[Set the html accesskey attribute on rendered html element]]></description>
<name>accesskey</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[The action to generate the URL for, if not using value]]></description>
<name>action</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>......................................................
.....................................
第二行有它的实现类找到 copy到自己的src以下 包名什么的都要一样 反复没事,由于它会先去找自己的class再去找jar文件里的
源代码例如以下:
public class AnchorTag extends AbstractClosingTag {
private static final long serialVersionUID = -1034616578492431113L;
protected String href;
protected String includeParams;
protected String scheme;
protected String action;
protected String namespace;
protected String method;
protected String encode;
protected String includeContext;
protected String escapeAmp;
protected String portletMode;
protected String windowState;
protected String portletUrlType;
protected String anchor;
protected String forceAddSchemeHostAndPort;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Anchor(stack, req, res);
}
protected void populateParams() {
super.populateParams();
Anchor tag = (Anchor) component;
tag.setHref(href);
tag.setIncludeParams(includeParams);
tag.setScheme(scheme);
tag.setValue(value);
tag.setMethod(method);
tag.setNamespace(namespace);
tag.setAction(action);
tag.setPortletMode(portletMode);
tag.setPortletUrlType(portletUrlType);
tag.setWindowState(windowState);
tag.setAnchor(anchor);
if (encode != null) {
tag.setEncode(Boolean.valueOf(encode).booleanValue());
}
if (includeContext != null) {
tag.setIncludeContext(Boolean.valueOf(includeContext).booleanValue());
}
if (escapeAmp != null) {
tag.setEscapeAmp(Boolean.valueOf(escapeAmp).booleanValue());
}
if (forceAddSchemeHostAndPort != null) {
tag.setForceAddSchemeHostAndPort(Boolean.valueOf(forceAddSchemeHostAndPort).booleanValue());
}
}
public void setHref(String href) {
this.href = href;
}
public void setEncode(String encode) {
this.encode = encode;
} //这里省略好多get set 方法
然后在自己copy过来的源代码中增加 doEndTag()方法。
。。
能够操作s:a标签中的属性,推断权限 等等 增加后代码例如以下
@Override
public int doEndTag() throws JspException {
//当前用户
User user=(User) pageContext.getSession().getAttribute("user"); //当前要显示的权限的相应的url
String privUrl=action; // 注意edit 和editUI 都相应edit
//去掉后面的參数
int pos=privUrl.indexOf("?");
if(pos>-1){
privUrl= privUrl.substring(0, pos); }
//去掉UI
if(privUrl.endsWith("UI")){ privUrl= privUrl.substring(0, privUrl.length()-2);
}
if(user.hasPrivilegeByUrl("/"+privUrl)/*有权限吗*/){
return super.doEndTag();//正常的生成并显示超链接标签 并继续运行后面的代码
}
else
{ return EVAL_PAGE;//什么都不做 (不显示超链接)仅仅是继续运行后面页面的代码
} }
OA 权限控制的更多相关文章
- 尝试asp.net mvc 基于controller action 方式权限控制方案可行性
微软在推出mvc框架不久,短短几年里,版本更新之快,真是大快人心,微软在这种优秀的框架上做了大量的精力投入,是值得赞同的,毕竟程序员驾驭在这种框架上,能够强力的精化代码,代码层次也更加优雅,扩展较为方 ...
- MongoDB 安全和访问权限控制
MongoDB的访问控制能够有效保证数据库的安全,访问控制是指绑定Application监听的IP地址,设置监听端口,使用账户和密码登录 一,访问控制的参数 1,绑定IP地址 mongod 参数:-- ...
- WebGIS中快速整合管理多源矢量服务以及服务权限控制的一种设计思路
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 在真实项目中,往往GIS服务数据源被其他多个信息中心或者第三方 ...
- ASP.NET MVC实现权限控制
这篇分享一下 ASP.NET MVC权限控制.也就是说某一用户登录之后,某一个用户是否有权限访问Controller,Action(操作),视图等 想实现这些功能,需要在数据库创建好几个表:[User ...
- springmvc+spring+mybatis+maven项目集成shiro进行用户权限控制【转】
项目结构: 1.maven项目的pom中引入shiro所需的jar包依赖关系 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
- Appfuse:权限控制
Appfuse的权限控制依赖于Struts的Menu机制,common下的menu.jsp是对菜单顺序的定义,详细的菜单项和菜单链接及权限再menu-config.xml中控制,如下: <Men ...
- .NET WebAPI 用ActionFilterAttribute实现token令牌验证与对Action的权限控制
项目背景是一个社区类的APP(求轻吐...),博主主要负责后台业务及接口.以前没玩过webAPI,但是领导要求必须用这个(具体原因鬼知道),只好硬着头皮上了. 最近刚做完权限这一块,分享出来给大家.欢 ...
- 浅谈Yii-admin的权限控制
说到CMS,最需要有的东西就是权限控制,特别是一些复杂的场景,多用户,多角色,多部门,子父级查看等等.最近在开发一个线下销售的东东,这个系统分为管理员端,省代端,客户端,门店端,销售端, 部门端,部门 ...
- Go语言实战 - revel框架教程之权限控制
一个站点上面最基本都会有三种用户角色,未登录用户.已登录用户和管理员.这一次我们就来看看在revel框架下如何进行权限控制. 因为revel是MVC结构的,每一个url其实都会映射到一个具体的Cont ...
随机推荐
- ftp报错 200 port command successful. consider using pasv 425 failed to establish connection
最近在公司做的项目是需要在客户端录制视频,然后通过ftp传到服务器端.客户端是windows,服务器端linux.今天用新的电脑配置好项目之后,测试数据传输时出现了“200 port command ...
- Unity Easy Save简单实用
Easy Save使用: 1.保存游戏进度 2.设计游戏关卡(怪物数量,坐标,背景图等等) Easy Save默认存储地址: C:\Users\Administrator\AppData ...
- iOS SDK原生JSON解析
- (IBAction)touchReadButton:(id)sender { NSData *jsonData = [[NSData alloc] initWithContentsOfFile:J ...
- java面试题集1
一:单选题 下列哪一种叙述是正确的(D )A. abstract修饰符可修饰字段.方法和类B. 抽象方法的body部分必须用一对大括号{ }包住C. 声明抽象方法,大括号可有可无D. 声明抽象方法不可 ...
- 高效CSS書寫規範及CSS兼容性
一.選擇器針對性說明 某一元素的多个规则集中,选择器的针对性越高,该规则集的权重也就越高.针对性相同的,后出现的规则集的权重更高. * {} /* a=0 b=0 c=0 d=0 -> spec ...
- SpringMVC的值传递
值的传递分为从页面传到到controller和从controller传递到页面,下面分别进行介绍: package com.springmvc.web; import java.util.Map; i ...
- 基于纹理边缘抑制的轮廓和边界检测(Contour and Boundary Detection)
基于纹理边缘抑制的轮廓和边界检测(Contour and Boundary Detection) kezunhai@gmail.com http://blog.csdn.net/kezunhai 一幅 ...
- 更新-----Scripts:执行双网卡绑定
#!/bin/bash #------------------------------------------------------------------------------- # Name: ...
- git使用经验
一直想写一点关于git的文章,但是平时太懒了,没有写,现在写些经验这里,方便以后自己忘记了.
- ExtJs4.0入门错误
当在eclipse中的web工程中增加了extjs4,出现An internal error occurred during: "Building workspace". Java ...