网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Struts2中怎么利用interceptor实现权限管理

Struts2中怎么利用interceptor实现权限管理,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

站在用户的角度思考问题,与客户深入沟通,找到望花网站设计与望花网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站设计、做网站、企业官网、英文网站、手机端网站、网站推广、域名注册、虚拟空间、企业邮箱。业务覆盖望花地区。

Xml代码

                                                        

Java代码

@Override        public String intercept(ActionInvocation invoke) throws Exception {             // TODO Auto-generated method stub             HttpSession session  = ServletActionContext.getRequest().getSession();             ApplicationContext context = Util.getContext(ServletActionContext.getServletContext());             PriorityService priorityService = context.getBean(PriorityService.class);                          String actionName = invoke.getProxy().getActionName();             String methodName = invoke.getProxy().getMethod();             if ("execute".equals(methodName))                  methodName = "index";             int index = actionName.indexOf("/");             String name = actionName.substring(0, index);                          Priority priority = priorityService.find(name, methodName);             Object obj = session.getAttribute("user");             if (obj != null) {                 User currentUser = (User) obj;                                  ModuleService moduleService = context.getBean(ModuleService.class);                 Module module = moduleService.findByUrl(name+"/"+methodName);                 if (module != null) {                     SystemDiaryService sdService = context.getBean(SystemDiaryService.class);                     SystemDiary diary = new SystemDiary();                     diary.setOperator(currentUser);                     diary.setOperateModule(module.getName());                     sdService.add(diary);                 }                                  if (priority != null) {                     boolean hasPermission = currentUser.hasPermission(priority);                                          if (!hasPermission) {                         return "forbidden";                     }                 }             }     //      System.out.println("name = "+name + "**actionName = "+actionName+"*methodName = "+methodName);                 String result = invoke.invoke();             return result;         }

看完上述内容,你们掌握Struts2中怎么利用interceptor实现权限管理的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


分享题目:Struts2中怎么利用interceptor实现权限管理
网站网址:http://bjjierui.cn/article/gjcoso.html

其他资讯