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
相关文档:
著作权保护声明
Chinaitlab高度重视知识产权保护并遵守中国各项知识产权法律、法规和具有约束力规范性文件。根据法律、法规和规范性文件要求,Chinaitlab
制定了旨在保护知识产权权利人合法权益的措施和步骤,当著作权人和/或依法可以行使著作权的权利人(以下简称“权利人”)发现在本站网页的内容或下
&nbs ......
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 ......
一、面向对象的特征有哪些方面
1.抽象:
抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节。抽象包括两个方面,一是过程抽象,二是数据抽象。
2 ......
package ch01;
2
3public class BubbleSort
4{
5
6
7 public static void main(String[] args){
8 int[]& ......
<%@ page language="java" import="java.util.*" pageEncoding="GBK"
import="java.awt.*,java.awt.image.*,javax.imageio.*"%><%
/*
使用方法:在需要显示验证码的html代码中使用<img p">
在需判断session的时候判断session.getAttribute("vcode")
*/try{
int codeLength=4;//验 ......