Struts has detected an unhandled exception错误原因及解决方法

发布于 2011-05-30 | 更新于 2020-09-20

使用Struts2进行开发时,经常会遇到下面这样的问题:

Struts Problem Report
Struts has detected an unhandled exception:

而问题的原因可能有很多,但是一般来说都是因为运行时遇到了不能识别的标识的错误,包括类名,路径名,方法名等,只要按照具体的错误提示内容仔细检查整个页面的运行流程涉及到的程序代码,就可以找出错误的原因了。

如下面遇到了该错误信息:

首先显示

Struts Problem Report
Struts has detected an unhandled exception:

可以发现是这类错误,然后下面继续有详细的错误提示:

Unresolved compilation problems: Question cannot be resolved to a type questions cannot be resolved
Could not instantiate bean class [com.exam.student.actions.UploadAction]:
Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: Question cannot be resolved to a type questions cannot be resolved

由此可以发现应该是Question相关的变量questions的类型没有定义好,于是找到上面提示的UploadAction查看,发现

private List questions;

这里忘记了些List的类型,应该改成这样:

private List questions;

为了确保正确修改,重新部署项目,正常访问。

遇到这类问题只能根据详细的提示信息查找相关代码仔细的检查了,包括看看有没有拼写错误,路径有没有写错,方法名,或是重启服务器,重新部署。

本文作者: arthinking

本文链接: https://www.itzhai.comstruts-has-detected-an-unhandled-exception-error-causes-and-solutions.html

版权声明: 版权归作者所有,未经许可不得转载,侵权必究!联系作者请加公众号。

×
IT宅

关注公众号及时获取网站内容更新。