兄弟们,我最近在研究spring的aop权限管理这一块,我想在执行某个方法前如(struts 的action中execute())注入判断权限的advice,如果权限不合法则抛出异常,这个权限是存储在session中的,那么关键advice如何能得到这个session中的值.
我的思路是
public class advice
{
if(!getSessionValue(PageContext context).equals("xxxx"))
{
throw new myException("对不起,你无权操作此功能!");
}
public String getSessionValue(PageContext context)
{
HttpSession session=congtext.getSession();
retrun session.getAttribute("userqx");
}
}
但是我做了一个示例好像不行呀!有没有好的实现方法!
我的思路是
public class advice
{
if(!getSessionValue(PageContext context).equals("xxxx"))
{
throw new myException("对不起,你无权操作此功能!");
}
public String getSessionValue(PageContext context)
{
HttpSession session=congtext.getSession();
retrun session.getAttribute("userqx");
}
}
但是我做了一个示例好像不行呀!有没有好的实现方法!
String PersonName= String.valueOf(session.getValue("personName"));
{
throw new myException("对不起,你无权操作此功能!");
}这样写语法正确吗?至于session不转换成String能不能用equals("****")
我不是很清楚