日期:2014-05-17  浏览次数:20636 次

求助:struts2 invocation.invoke() 调用错误!
我使用的是myeclipse 6.5,使用的架构是struts2+spring

在做权限过滤是,我使用了struts2的拦截器。

具体的拦截程序如下:

public String interceptASC(ActionInvocation invocation) throws Exception
{
System.out.print("------------------------进入拦截-------------------------");

ActionContext ctx = invocation.getInvocationContext();
ActionContext context = ActionContext.getContext();
Map session = ctx.getSession();
String userid = (String)session.get("userid");
userid="67";
String resultStr="";
boolean checkP=false;
if(userid==null || userid.equals(""))
{
context.put("messageStr", "你的登录信息已过期,请重新登陆。");
System.out.println("---------------用户登录过期----------------");
resultStr="messagePage";
}
else
{
String getname=(String)ctx.getName();
System.out.println("-------获取actionName-----------getname="+getname);
 
if(getname.contains("-----"))
{
System.out.println("---------------进行拦截----------------");

  //此处是进行权限判定
  checkP=checkClass.checkPerm("68", "栏目访问权限路径");
if(checkP==true)
resultStr=invocation.invoke();
else
{
System.out.println("---------------错误,无权限!----------------");
context.put("messageStr", "你没有权限执行该操作");
resultStr="messagePage";
}
}
else
{
resultStr=invocation.invoke();
}
}


return resultStr;
}


结果,每次在运行到 resultStr=invocation.invoke();时,有错误问题,在调试的时候,一到resultStr=invocation.invoke();时,就会跳到DefaultActionInvocation.class
Class File Editor

Source not found

the source attachement does not contain the source for the file DefaultActionInvocation.class.
You can change the source attachment by clicking Change Attached Source below:




但是我看在我的workspace下面,本项目的webroot/web-inf/lib/ 有 xwork-core-2.1.6.jar
包括在发布目录下,也有xwork-core-2.1.6.jar

我也尝试打开xwork-core-2.1.6.jar,里面有引用的DefaultActionInvocation.class

这个问题困扰我很久了,希望各位高手能帮帮忙,多谢了!

------解决方案--------------------
你调试的时候当然是一步步地进入了 Source not found

是因为你没有关联源文件么 所以eclipse在你调试时要找那个类文件时提示给你信息

报错信息是什么
------解决方案--------------------
DefaultActionInvocation 是 ActionInvocation 的实现所以肯定会跳到这个类里面,因为你就是使用这个对象进行invoke的。
至于前台页面为空 :你不是说 “有错误问题”吗?什么问题
还有 可能是你配置导航到前台的页面配置错误...有机前台页面看看是否有源代码..

另外把拦截器去掉看看能否正常运行...先保证整个流程能执行 再加拦截器