把所有Action及其包含的Methodr入库保存,然后用Filter检测
解决方案 »
- Java使用.cer文件中的公钥对密码加密
- struts 1.2 标签 html:img 无法显示图片
- 请教ibatis的DBCP连接池和tomcat6的优化问题
- ireport+struts2导出excel报错 其他都行
- 代码无法更新的问题,哪位有个类似经历的帮帮我
- sax解析xml文件,当找到合适的数据后怎么停止解析
- eclipse3.4为什么运行方式没有swt方式?
- 求助:看不懂的错误提示
- 在线求助高手,编JSP查询的SQL问题,100分
- 用EJB获取home接口时,出现java.lang.ClassCastException是怎么回事
- 求救!!!各位学长请帮帮我,hibernate 问题
- 最近在学习iReport,谁用详细点的教程?
if(method.equals("add")){//do something}
if(method.equals("delete")){//do something}else{SYSOUT("error");}
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>
或
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page> ps:上面的exception可以细分很多种
在方法中抛出一个异常,告诉用户
你所访问的资源不存在
”,你说的背离题干啦,哈哈
public void dispatchMethod (){}
}public class BookAction extends SelfDispatchAction{
}
在方法中抛出一个异常,告诉用户
你所访问的资源不存在
这个就是答案,我都看的恼火了
在web.xml里面使用
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsp</location>
</error-page>
或
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
...另外,即使是get方法,仍旧会调用到form的validate的。只不过你的问题确实和这个无关就是。最后,我想知道ActionExceptionHandler是在什么时候调用的?按道理你的问题应该会抛出异常,然后调用到ActionExceptionHandler的。
然后对 NoSuchMethodException 进行捕捉 然后处理
try {
return super.dispatchMethod(mapping, form, request, response, method);
} catch(NoSuchMethodException e) {
return mapping.findForward("");
}
然后在这个类中 覆盖 dispatchMethod 方法
然后自己其它的类再继承自己的这个类想必 这个你也知道的 :-)不过这样日志里依然会有
org.apache.struts.actions.DispatchAction dispatchMethod
严重: Action[/book] does not contain method named 'addadd'
诸如此类的 异常记录
但是 可以 “能够转到我事先制作的一个页面”
2、既然已经捕捉了这个异常,那么,如何使得日志不产生这个异常信息(注意,是让它根本不产生,不是通过调整日志的错误级别来忽略这个Error信息在日志文件中写入)
---我的过滤器的核心代码如下:在doFilter()方法里面,加入代码:
...
if (session.getAttribute("ACCOUNT_NAME") == null) {
httpres.sendRedirect(httpreq.getContextPath() + "/login.jsp");
} else {
if (httpreq.getHeader("Referer") == null) {
httpres.sendRedirect(httpreq.getContextPath() + "/ForbidModUrlBar.jsp");
return;
} filterChain.doFilter(request, response);
}
...
return super.dispatchMethod(mapping, form, request, response, method);
} catch(NoSuchMethodException e) {
return mapping.findForward("");
}