struts如何防止 NoSuchMethodException

来源:百度知道 编辑:UC知道 时间:2024/05/20 13:26:09
如何防止在地址栏输入不存在的方法,服务器端不报这个异常。
高手请指教,谢谢。

你是指DispatchAction的子类吗?
那么这么做看看,Action不是有个对应的Form吗?你在该form的validate方法中加上一下代码,比如你的parameter是method吧.
public ActionErrors validate(...){
if(method==null||(!"方法1".equals(method)&&!"方法2".equals(method)...其他方法)
method="方法3";
}
就是用一个方法3去处理所有的没有对应方法的请求.