当前位置:

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

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

异常

javax。servlet。jsp。JspException: Missing message for key xx。xx。xx

Probable Causes

这个key的值对没有在资源文件ApplicationResources。properties中定义。如果你使用eclipse时经常碰到这样的情况,当项目重新编译时,eclipse会自动将classes目录下的资源文件删除。

资源文件ApplicationResources。properties 不在classpath中应将资源文件放到 WEBINF/classes 目录下,当然要在strutsconfig。xml中定义)

异常

Cannot find message resources under key org。apache。struts。action。MESSAGE

可能原因

很显然,这个错误是发生在使用资源文件时,而Struts没有找到资源文件。

Implicitly trying to use message resources that are not available (such as using empty html:options tag instead of specifyingthe options in its body this assumes options are specified in ApplicationResources。properties file)

XML parser issues too many, too few, incorrect/incompatible versions

异常

Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet。

可能原因

混和使用Struts的html:form标记和标准的HTML标记不正确。

使用的编码样式在本页中不支持。

异常

"Document contained no data" in Netscape

No data rendered (completely empty) page in Microsoft Internet Explorer

可能原因

使用一个Action的派生类而没有实现perform()方法或execute()方法。在Struts1。0中实现的是perform()方法,在Struts1。1中实现的是execute()方法,但Struts1。1向后兼容perform()方法。但你使用Struts1。1创建一个Action的派生类,并且实现了execute()方法,而你在Struts1。0中运行的话,就会得到"Document contained nodata" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer。”的错误信息。

异常

ServletException: BeanUtils。populate

解决方案

在用Struts上传文件时,遇到了javax。servlet。ServletException: BeanUtils。populate异常。

我的ActionServlet并没有用到BeanUtils这些工具类。后来仔细检查代码发现是在jsp文件里的form忘了加enctype=quot;multipart/formdataquot; 了。所以写程序遇到错误或异常应该从多方面考虑问题存在的可能性,想到系统提示信息以外的东西。

1。 定义Action后, 如果指定了name, 那么必须要定义一个与它同名的FormBean才能进行form映射。2。 如果定义Action后, 提交页面时出现 "No input attribute for mapping path。。。" 错误, 则需要在其input属性中定义转向的页面。3。 如果插入新的数据时出现 "Batch update row count wrong:。。。" 错误, 则说明XXX。hbm。xml中指定的key的类型为原始类型(int, long),因为这种类型会自动分配值, 而这个值往往会让系统认为已经存在该记录, 正确的方法是使用java。lang。Integer或java。lang。Long对象。4。 如果插入数据时出现 "argument type mismatch" 错误, 可能是你使用了Date等特殊对象, 因为struts不能自动从String型转换成Date型,所以, 你需要在Action中手动把String型转换成Date型。5。 Hibernate中, Query的iterator()比list()方法快很多。6。 如果出现 "equal symbol expected" 错误, 说明你的strtus标签中包含另一个标签或者变量, 例如:

html:select property="test" onchange="%=test%"/

或者

html:hidden property="test" value="bean:write name="t" property="p"/"/

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

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

(责任编辑:xy)

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

考试科目