dha*_*0us 8 java spring spring-mvc shiro
我使用Shiro注释来检查这样的授权:
@RequiresPermissions("addresses:list")
public ModelAndView getCarrierListPage() {
return new ModelAndView("addressList", "viewData", viewData);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:如果用户没有注释所需的权限,则抛出异常.如果发生异常,我宁愿将用户重定向到其他URL.我怎么做?
这是我的shiro过滤器配置:
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/showLoginPage"/>
<property name="filterChainDefinitions">
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
看起来你正在使用 Spring。我通过在控制器中提供 ExceptionHandler 在 SpringMVC 中处理了这个问题。
@ExceptionHandler(TheSpecificException.class)
protected ModelAndView handleSpecificException(ApplicationException e, HttpServletRequest request)
{
// code to handle view/redirect here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1699 次 |
| 最近记录: |