java 中用户访问权限(spring 权限管理)
// AuthorityInterceptor.java 文件
package com.aptech.jb.epet.web.authority;
import javax.servlet.http.HttpServletRequest;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.struts.action.ActionMapping;
public class AuthorityInterceptor implements MethodInterceptor {
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
System.out.println("=============AuthorityInterceptor==="+methodInvocation.getMethod().getName());
HttpServletRequest request=null;
ActionMapping mapping=null;
Object [] args=methodInvocation.getArguments();
for(int i=0;i<args.length;i++){
//左边是否是右边的一实例
if(args[i] instanceof HttpServletRequest)
request=(HttpServletRequest) args[i];
if(args[i] instanceof ActionMapping)
mapping=(ActionMapping) args[i];
}
if(request.getSession().getAttribute("CURRENT_PET")!=null){
return methodInvocation.proceed();
}else{
return mapping.findForward("index");
}
}
}
------------------------------------------------------------------------
------------------spring 配置文件如下------------------
-----authorityInterceptor 为 AuthorityInterceptor 的实例。
<!-- 自动创建权限代理 -->
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">0
<list>
<value>/pet</value>
<value>/diary</value> //不能包含当前登录Action path 路径
</list>
</property>
<property name="interceptorNames">
&n
相关文档:
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
1.Prototyping: in general (Enterprise) Java projects start with evaluation which frameworks to use. This can take from few hours, to several months (although these times are hopefully over). Java EE 6 comes with “one stop shopping”. You can download Java EE 6 with the IDE (eclipse, netbe ......
Java与XML联合编程之DOM篇
DOM初步
DOM
是Document Object
Model的缩写,即文档对象模型。前面说过,XML将数据组织为一颗树,所以DOM就是对这颗树的一个对象描叙。通俗的说,就是通过解析XML文档,为
XML文档在逻辑上建立一个树模型,树的节点是一个个对象。我们通过存取这些对象就能够存取XML文档的内容。 ......
char[] cha = operator.toCharArray();
char ch = cha[0];
double sum = 0;
switch (ch) {
&nb ......