




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
struts2 异常处理总结1-:java.lang.NoClassDefFoundError: org/apache/struts2/dojo/views/jsp/ui/HeadTag解决办法:原因缺少了dojo的JAR包,引入即可:struts2-dojo-plugin-2.1.2.jarThe head tag renders required JavaScript code to configure Dojo and is required in order to use any of the tags included in the Dojo plugin.-If you are planning to nest tags from the Dojo plugin, make sure you set parseContent=false, otherwise each request made by the inner tags will be performed twice.2-:Unable to load configuration. -bean -jar:file:/F:/Struts2/Struts2/WebRoot/WEB-INF/lib/struts2-core- 2.1.2.jar!/struts-default.xml:46:178Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest -bean -jar:file:/F:/Struts2/Struts2/WebRoot/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext解决办法:缺少JAR包,引入commons-fileupload-1.2.1.jar,commons-io-1.3.2.jar即可3-:No tag datetimepicker defined in tag library imported with prefix s原因版本问题:缺少struts-dojo-plugin JAR包,以及HTML的,中没有使用标签If youre using Struts 2.1.x youre probablymissing thestruts-dojo-plugin. Michals reference below applies to Struts 2.1.xonly. In the lasts versions (since 2.0.9 I guess), all AJAX are in dojo plugin. So you need toinclude and ( Temp1:Temp2:Temp3:Temp4:) and call :4-:使用TILES框架If you use the Tiles 2 plugin, check your tiles.xml file(s) to ensure they contain a DOCTYPE.5-:struts2中不支持EL表达式 Struts2.1 tags do not allow evaluation of JSP EL within their attributes.Instead, Struts2 tags evaluate attribute values as OGNL. Allowing bothexpression languages within the same attribute opens major securityvulnerabilities. 6-文件上传过程中取不到文件名和文件类型,即都取到NULL原因:如果页面中file的name=“a”则我们ACTION中设置String aContentType,String aFileName;(此两个其实无所谓,关键是SET方法)setA(File file)(); setAContentType(String s);setAFileName(String name) 即格式如下:setXContentType() setXFileName().X代表你给FILE取的NAME名字必须和它相同,固定格式7-严重: Unable to parse mons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (8523356) exceeds the configured maximum (2097152)at mons.fileupload.FileUploadBase$FileItemIteratorImpl.(FileUploadBase.java:914)2008-5-27 17:46:51 mons.CommonsLogger warn警告: Could not find property struts.valueStack2008-5-27 17:46:51 mons.CommonsLogger error严重: the request was rejected because its size (8523356) exceeds the configured maximum (2097152)2008-5-27 17:46:51 mons.CommonsLogger warn警告: Could not find property org.apache.catalina.jsp_file原因:上传文件大小超过预定大小,可以在perties配置文件中设置struts.multipart.maxSize=XXX(XXX为文件大小)8-配置了文件类型限制后,当传错误类型可以拦截不让用户上传该文件,可是跳转的页面却没有跳转到input配置的错误页面,而是返回到了success正确页面。严重: Content-Type not allowed: filedata upload_5b01657_11a329d4dcf_8000_00000000.tmp text/plain我的打印输出DEBUG语句内容:File:null FlieName:null type:null即拦截类型成功了java.lang.NullPointerExceptionat java.io.FileInputStream.(FileInputStream.java:103)at com.study.web.util.FileUploadUtil.uploadFile(FileUploadUtil.java:36)at com.study.web.action.UploadFileAction.execute(UploadFileAction.java:58)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)。2008-5-29 10:59:07 mons.CommonsLogger warn警告: Could not find property org.apache.catalina.jsp_file2008-5-29 10:59:07 mons.CommonsLogger warn警告: Could not find property struts2008-5-29 10:59:07 mons.CommonsLogger info信息: Removing file filedata tmpupload_5b01657_11a329d4dcf_8000_00000000.tmp原因及解决办法:在该文件上传Action中只配置了FileUploadInterceptor后缺少配置了defaultStack拦截器.在ACTION中配置玩defaultStack拦截器后改错误消失。9-perties中全局配置文件大小,再使用默认FileUploadInterceptor拦截器时候能实现拦截的功能但是后台出现异常。严重: Unable to parse mons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (380) exceeds the configured maximum (10)at mons.fileupload.FileUploadBase$FileItemIteratorImpl.(FileUploadBase.java:914)原因:未知。将全局配置中的限制大小去掉,再重新在ACTION中覆盖配置FileUploadInterceptor拦截器设置大小和文件类型限制,可消除异常。10-多文件上传中,其中一个传被限制的文件如限制aplication/msword(即.doc)文件,允许传文本文件。然而当夹杂在一起传的时候,后台能截获类型错误不可传信息,但是实际却还是上传成功。严重: Content-Type not allowed: filedata upload_4d958287_11a33e76ab9_8000_00000007.tmp application/mswordfile is :tmpupload_4d958287_11a33e76ab9_8000_00000006.tmp fileName:project.txt fileType:text/plainfile is :tmpupload_4d958287_11a33e76ab9_8000_00000007.tmp fileName:application base.doc fileType:application/mswordfile is :tmpupload_4d958287_11a33e76ab9_8000_00000008.tmp fileName:zhongqi-bug.txt fileType:text/plain原因:忘记了继承ActionSupport类。继承后异常消失。11-文件上传异常,不能创建File文件Cannot create type class java.io.File from value C:Documents and Settingsadmin桌面OrderReporterServiceImp.java - unknown location原因:忘记了在form表单里将enctype设置成文件上传格式:enctype=multipart/form-data12-当使用限制文件类型和大小的时候抛出空指针异常java.lang.NullPointerExceptiondemo.struts2.action.ValidatFileUploadAction.execute(ValidatFileUploadAction.java:71)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)原因:在ACTION中配置了fileUpload拦截器后忘记了配置默认拦截器:defautlStack。注意当ACTION中配置自己的拦截器后需要显示配置默认拦截器defaultStack13-在国际化时候抛空指针异常:16:31:12,812 ERROR jsp:253 - Servlet.service() for servlet jsp threw exceptionjava.lang.NullPointerException at java.text.MessageFormat.applyPattern(MessageFormat.java:414)at java.text.MessageFormat.(MessageFormat.java:350)at com.opensymphony.xwork2.DefaultTextProvider.getText(DefaultTextProvider.java:70)原因:忘记了在struts.xml中配置国际化常量,或者在perties中配置全局国际化常量 struts.custom.i18n.resources=globeMessage14- struts action的配置文件加载失败:Unable to load configuration. - result - file:/D:/Java/apache-tomcat-5.5.20/webapps/mysts/WEB-INF/classes/test.xml:10:26Caused by: No result type specified for result named error, perhaps the parent package does not specify the result type? - result - file:/D:/Java/apache-tomcat-5.5.20/webapps/mysts/WEB-INF/classes/test.xml:10:26at viders.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:609)原因:忘记了继承包struts-default15- struts action 配置文件注意事项:1. 别忘记了继承struts-default默认配置包2.如果配置命名空间,一定要以/开始,例如:namespace=/test3.每个模块struts action配置文件中都可以配置全局result,global-result 经测试不会冲突,STRTUS会智能寻找该Action请求的模块STRUTS ACTION配置包关键字: 警告: no configuration found for the specified action 警告: No configuration found for the specified action: ShowMessage in namespace: . Form action defaulting to action attributes literal value. 解决方法:经过测试发现,是没有正确使用tag的原因,这种情况下,正确的写法应该是, 您是否添加了action这个呢?1-:java.lang.NoClassDefFoundError: org/apache/struts2/dojo/views/jsp/ui/HeadTag解决办法:原因缺少了dojo的JAR包,引入即可:struts2-dojo-plugin-2.1.2.jarThe head tag renders required JavaScript code to configure Dojo and is required in order to use any of the tags included in the Dojo plugin.-If you are planning to nest tags from the Dojo plugin, make sure you set parseContent=false, otherwise each request made by the inner tags will be performed twice.2-:Unable to load configuration. -bean -jar:file:/F:/Struts2/Struts2/WebRoot/WEB-INF/lib/struts2-core- 2.1.2.jar!/struts-default.xml:46:178Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest -bean -jar:file:/F:/Struts2/Struts2/WebRoot/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext解决办法:缺少JAR包,引入commons-fileupload-1.2.1.jar,commons-io-1.3.2.jar即可3-:No tag datetimepicker defined in tag library imported with prefix s原因版本问题:缺少struts-dojo-plugin JAR包,以及HTML的,中没有使用标签If youre using Struts 2.1.x youre probablymissing thestruts-dojo-plugin. Michals reference below applies to Struts 2.1.xonly. In the lasts versions (since 2.0.9 I guess), all AJAX are in dojo plugin. So you need toinclude and ( Temp1:Temp2:Temp3:Temp4:) and call :4-:使用TILES框架If you use the Tiles 2 plugin, check your tiles.xml file(s) to ensure they contain a DOCTYPE.5-:struts2中不支持EL表达式 Struts2.1 tags do not allow evaluation of JSP EL within their attributes.Instead, Struts2 tags evaluate attribute values as OGNL. Allowing bothexpression languages within the same attribute opens major securityvulnerabilities. 6-文件上传过程中取不到文件名和文件类型,即都取到NULL原因:如果页面中file的name=“a”则我们ACTION中设置String aContentType,String aFileName;(此两个其实无所谓,关键是SET方法)setA(File file)(); setAContentType(String s);setAFileName(String name) 即格式如下:setXContentType() setXFileName().X代表你给FILE取的NAME名字必须和它相同,固定格式7-严重: Unable to parse mons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (8523356) exceeds the configured maximum (2097152)at mons.fileupload.FileUploadBase$FileItemIteratorImpl.(FileUploadBase.java:914)2008-5-27 17:46:51 mons.CommonsLogger warn警告: Could not find property struts.valueStack2008-5-27 17:46:51 mons.CommonsLogger error严重: the request was rejected because its size (8523356) exceeds the configured maximum (2097152)2008-5-27 17:46:51 mons.CommonsLogger warn警告: Could not find property org.apache.catalina.jsp_file原因:上传文件大小超过预定大小,可以在perties配置文件中设置struts.multipart.maxSize=XXX(XXX为文件大小)8-配置了文件类型限制后,当传错误类型可以拦截不让用户上传该文件,可是跳转的页面却没有跳转到input配置的错误页面,而是返回到了success正确页面。严重: Content-Type not allowed: filedata upload_5b01657_11a329d4dcf_8000_00000000.tmp text/plain我的打印输出DEBUG语句内容:File:null FlieName:null type:null即拦截类型成功了java.lang.NullPointerExceptionat java.io.FileInputStream.(FileInputStream.java:103)at com.study.web.util.FileUploadUtil.uploadFile(FileUploadUtil.java:36)at com.study.web.action.UploadFileAction.execute(UploadFileAction.java:58)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)。2008-5-29 10:59:07 mons.CommonsLogger warn警告: Could not find property org.apache.catalina.jsp_file2008-5-29 10:59:07 mons.CommonsLogger warn警告: Could not find property struts2008-5-29 10:59:07 mons.CommonsLogger info信息: Removing file filedata tmpupload_5b01657_11a329d4dcf_8000_00000000.tmp原因及解决办法:在该文件上传Action中只配置了FileUploadInterceptor后缺少配置了defaultStack拦截器.在ACTION中配置玩defaultStack拦截器后改错误消失。9-perties中全局配置文件大小,再使用默认FileUploadInterceptor拦截器时候能实现拦截的功能但是后台出现异常。严重: Unable to parse mons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (380) exceeds the configured maximum (10)at mons.fileupload.FileUploadBase$FileItemIteratorImpl.(FileUploadBase.java:914)原因:未知。将全局配置中的限制大小去掉,再重新在ACTION中覆盖配置FileUploadInterceptor拦截器设置大小和文件类型限制,可消除异常。10-多文件上传中,其中一个传被限制的文件如限制aplication/msword(即.doc)文件,允许传文本文件。然而当夹杂在一起传的时候,后台能截获类型错误不可传信息,但是实际却还是上传成功。严重: Content-Type not allowed: filedata upload_4d958287_11a33e76ab9_8000_00000007.tmp application/mswordfile is :tmpupload_4d958287_11a33e76ab9_8000_00000006.tmp fileName:project.txt fileType:text/plainfile is :tmpupload_4d958287_11a33e76ab9_8000_00000007.tmp fileName:application base.doc fileType:application/mswordfile is :tmpupload_4d958287_11a33e76ab9_8000_00000008.tmp fileName:zhongqi-bug.txt fileType:text/plain原因:忘记了继承ActionSupport类。继承后异常消失。11-文件上传异常,不能创建File文件Cannot create type class java.io.File from value C:Documents and Settingsadmin桌面OrderReporterServiceImp.java - unknown location原因:忘记了在form表单里将enctype设置成文件上传格式:enctype=multipart/form-data12-当使用限制文件类型和大小的时候抛出空指针异常java.lang.NullPointerExceptiondemo.struts2.action.ValidatFileUploadAction.execute(ValidatFileUploadAction.java:71)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)原因:在ACTION中配置了fileUpload拦截器后忘记了配置默认拦截器:defautlStack。注意当ACTION中配置自己的拦截器后需要显示配置默认拦截器defaultStack13-在国际化时候抛空指针异常:16:31:12,812
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 现代物流运输安全管理实务手册
- 现代办公自动化系统操作应用教程
- 社交电商用户行为分析-第17篇-洞察与解读
- 中小学生时间管理与学习方法指导
- 制造行业车间噪声问题改善案例集
- 古代神话故事知识复习题库
- 一年级数学教案及课后习题详解
- 餐饮服务员工培训手册范例
- 建筑企业员工安全培训课程大纲
- 中型企业内部审计工作流程说明
- 康复科护士的康复科科普知识普及
- 中国居民赴巴基斯坦投资税收指南2023
- 安全驾驶指南图解
- 《夏夜荷花》阅读答案
- 投资最重要的事
- 2023年新高考I卷英语试题讲评课件-2024届高考英语一轮复习
- 2023年05月西藏林芝市司法局招考聘用专职人民调解员笔试题库含答案解析
- GB 19761-2020通风机能效限定值及能效等级
- 蚁群算法最全集课件
- 初中数学北师大九年级上册图形的相似-相似三角形的性质 市一等奖PPT
- 水利参考文件-土方回填检验批
评论
0/150
提交评论