Webwork Result失效的一个错误

访问Action.不能跳转到指定的jsp页面,有如下异常

java.lang.NoSuchMethodException: ch7.example6.TestJaserReport.getTtt.jsp()
java.lang.Class.getMethod(Class.java:1605)
ch7.example1.DebugResult.execute(DebugResult.java:23)
com.opensymphony.xwork.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:311)
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:206)

很奇怪,怎么会有getTtt.jsp()这么诡异的方法
突然想起我在xwork.xml中有一个自定义的result type,并把default设置成了true

       <result-types>
           <result-type name="debug" class="ch7.example1.DebugResult" default="true"/>
      </result-types> 

难怪,原本默认的result="dispatcher"现在变成了debug这个自定义的类,DebugResult的代码如下:

 

public   class  DebugResult  implements  Result  {
    
public static final String DEFAULT_PARAM="property";
    
    String property;
    
public void setProperty(String property) {
        
this.property = property;
    }

    
public void execute(ActionInvocation invocation) throws Exception {
           String resultCode
=invocation.getResultCode();
           System.out.println(
"ResultCode="+resultCode);
           Action action
=(Action)invocation.getAction();
           String methodName
="get"+property.substring(0,1).toUpperCase()+property.substring(1);
           Method method
=action.getClass().getMethod(methodName, new Class[0]);
           Object o
=method.invoke(action, new Object[0]);
           System.out.println(property
+":"+o);
           
    }


}

其中是要指定一个 public static final String DEFAULT_PARAM="property";的,而我现在用的action配置中并没有这个参数,而且我也没有指定result="debug" 所以,webwork把我的action跳转成debug类型的result,但并没有找到他需要的property,当然就报错了,webwork把我的jsp文件--/ch7/ttt.jsp当成参数,传到DebugResult中去解析了,所以会出现找不到getTtt.jsp()这种错误

 

解决:把default="true"去掉就好了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值