第一種:URL 級別粗粒度權限控制
配置 web.xml 的 shiroFilter 攔截 /*
在 spring 的 applicationContext*.xml 配置文件中配置同名 bean,配置
filterChainDefinitions 攔截控制規則
xxx.html* = anon (未登錄可以訪問) xxx.html* =authc (必須登錄才能訪問 ) xxx.html* = perms[權限] (需要特定權限才能訪問) xxx.html* = roles[角色] (需要特定角色才能訪問 )
第二種: 方法級別細粒度權限控制
在 spring 的 applicationContext*.xml 配置 spring aop 對 spring 管理 bean 對象開啓 shiro 註解支持
@RequiresPermissions(權限) 需要特定權限才能訪問
@RequiresRoles(角色) 需要特定角色才能訪問
@RequiresAuthentication 需要認證才能訪問
第三種:通過 shiro 自定義標籤,實現頁面元素顯示控制
<shiro:authenticated> 登錄後才能訪問
<shiro:hasPermission name="abc"> 需要特定權限才能訪問
<shiro:hasRole name="abc"> 需要特定角色才能訪問
第四種:在程序中通過代碼 判斷用戶是否具有指定權限( 不太常用 ,有代碼侵入 )