当前位置:

JAVA认证考试经验技巧之JAVA常见异常7

发表时间:2014/4/17 9:29:53 来源:互联网 点击关注微信:关注中大网校微信
关注公众号

可能原因

没有位form bean中的某个变量定义getter 方法

这个错误主要发生在表单提交的FormBean中,用struts标记html:text property=”username”时,在FormBean中必须有一个getUsername()方法。注意字母“U”。

异常

java。lang。NoClassDefFoundError: org/apache/struts/action/ActionForm

可能原因

这个错误主要发生在在classpath中找不到相应的Java 。class文件。如果这个错误发生在web应用程序的运行时,主要是因为指定的class文件不在web server的classpath中(/WEBINF/classes 和 /WEBINF/lib)。在上面的错误中,原因是找不到ActionForm类。

异常

javax。servlet。jsp。JspException: Exception creating bean of class org。apache。struts。action。ActionForm: {1}

可能原因

Instantiating Strutsprovided ActionForm class directly instead of instantiating a class derived off ActionForm。 This mightoccur implicitly if you specify that a formbean is this Struts ActionForm class rather than specifying a child of this classfor the formbean。

Not associating an ActionFormdescended class with an action can also lead to this error。

异常

javax。servlet。jsp。JspException: Cannot find ActionMappings or ActionFormBeans collection

可能原因

不是标识Struts actionServlet的servlet标记就是映射。do扩展名的sevletmapping标记或者两者都没有在web。xml中声明。

在strutsconfig。xml中的打字或者拼写错误也可导致这个异常的发生。例如缺少一个标记的关闭符号/。最好使用struts console工具检查一下。

另外,loadonstartup必须在web。xml中声明,这要么是一个空标记,要么指定一个数值,这个数值用来表servlet运行的优先级,数值越大优先级越低。

还有一个和使用loadonstartup有关的是使用Struts预编译JSP文件时也可能导致这个异常。

异常

java。lang。NullPointerException at org。apache。struts。util。RequestUtils。forwardURL(RequestUtils。java:1223)

可能原因

在strutsconfig。xml中的forward元素缺少path属性。例如应该是如下形式:

forward name="userhome" path="/user/userhome。jsp"/

异常

javax。servlet。jsp。JspException: Cannot find bean org。apache。struts。taglib。html。BEAN in any scope

Probable Causes

试图在Struts的form标记外使用form的子元素。这常常发生在你在/html:form后面使用Struts的html标记。另外要注意可能你不经意使用的无主体的标记,如html:form … /,这样web 服务器解析时就当作一个无主体的标记,随后使用的所有html标记都被认为是在这个标记之外的,如又使用了html:text property=”id”还有就是在使用taglib引入HTML标记库时,你使用的prefix的值不是html。

编辑推荐:JAVA认证考试经验技巧之JAVA常见异常汇总

更多关注:JAVA考试经验 JAVA辅导资料 JAVA历年真题

(责任编辑:xy)

2页,当前第1页  第一页  前一页  下一页
最近更新 考试动态 更多>

考试科目