strust2 如何拦截Struts Problem Report an unhandled exception:异常
问题描述:
struts2 如何拦截这样的异常
Struts Problem Report
Struts has detected an unhandled exception:
Messages: There is no Action mapped for namespace / and action name men2u.
不想看到这样的异常 我要自定义异常
答
:lol: 这个错误,还没来得及进入拦截器呢。就挂掉了。你可以配置容器级别的错误拦截在web.xml中。
[code="xml"]
java.lang.Exception
/err/error.jsp
或者
500
/err/error.jsp
[/code]
答
貌似请求错了,例如
配置文件配置的是
配置文件缺少 namespace="/men2u"
答
修改下面这个类引用的ftl文件,也能改变你的样式。
[code="java"]
org.apache.struts2.dispatcher.Dispatcher.sendError()
Template template = config.getTemplate("/org/apache/struts2/dispatcher/error.ftl");
[/code]
可以修改 sendError 方法输入其它的内容!~~反正就是一个Response的应答流!~~~掌握在你手中。 :lol:
答
你的自定义异常没有正确配上 men2u 那份,具体要查看你的配置文件。