<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    ply

    吞噬黑暗
    posts - 1, comments - 11, trackbacks - 0, articles - 13
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    struts2 異常處理總結

    Posted on 2011-09-02 23:07 ply 閱讀(1500) 評論(0)  編輯  收藏 所屬分類: 知識小串通

    1---:java.lang.NoClassDefFoundError: org/apache/struts2/dojo/views/jsp/ui/HeadTag

    解決辦法:原因缺少了dojo的JAR包,引入即可:struts2-dojo-plugin-2.1.2.jar

    The "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:178

    Caused 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:178

    Caused 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的,<HEAD></HEAD>中沒有使用<s:head/>標簽

    If you're using Struts 2.1.x you're probablymissing the>struts-dojo-plugin. Michal's 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 <%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
    > > and <sx:head/>
    > >( Temp1:
    <sx:datetimepicker name="picker" />
    Temp2:
    <sx:datetimepicker type="time" name="picker" /><br/>
    Temp3:
    <sx:datetimepicker value="%{'2008-06-08'}" name="picker" />
    Temp4:
    <sx:datetimepicker value="date" name="picker" />)
    > > and call :<sx:datetimepicker .../>

    4---:使用TILES框架

    If you use the Tiles 2 plugin, check your tiles.xml file(s) to ensure they contain a DOCTYPE.

    <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd"><tiles-definitions>


    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 request
    org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (8523356) exceeds the configured maximum (2097152)
    at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:914)2008-5-27 17:46:51 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
    警告: Could not find property [struts.valueStack]
    2008-5-27 17:46:51 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
    嚴重: the request was rejected because its size (8523356) exceeds the configured maximum (2097152)
    2008-5-27 17:46:51 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
    警告: Could not find property [org.apache.catalina.jsp_file]

    原因:上傳文件大小超過預定大小,可以在struts.properties配置文件中設置struts.multipart.maxSize=XXX(XXX為文件大?。?br />


    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.NullPointerException
    at java.io.FileInputStream.<init>(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 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
    警告: Could not find property [org.apache.catalina.jsp_file]
    2008-5-29 10:59:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
    警告: Could not find property [struts]
    2008-5-29 10:59:07 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Removing file filedata \tmp\upload__5b01657_11a329d4dcf__8000_00000000.tmp

    原因及解決辦法:在該文件上傳Action中只配置了FileUploadInterceptor后缺少配置了defaultStack攔截器.

    在ACTION中配置玩defaultStack攔截器后改錯誤消失。


    9---struts.properties中全局配置文件大小,再使用默認FileUploadInterceptor攔截器時候能實現攔截的功能但是后臺出現異常。

    嚴重: Unable to parse request
    org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (380) exceeds the configured maximum (10)
    at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:914)

    原因:未知。將全局配置中的限制大小去掉,再重新在ACTION中覆蓋配置FileUploadInterceptor攔截器設置大小和文件類型限制,可消除異常。


    10---多文件上傳中,其中一個傳被限制的文件如限制aplication/msword(即.doc)文件,允許傳文本文件。然而當夾雜在一起傳的時候,后臺能截獲類型錯誤不可傳信息,但是

    實際卻還是上傳成功。

    嚴重: Content-Type not allowed: filedata "upload_4d958287_11a33e76ab9__8000_00000007.tmp" application/msword
    file is :\tmp\upload_4d958287_11a33e76ab9__8000_00000006.tmp fileName:project.txt fileType:text/plain
    file is :\tmp\upload_4d958287_11a33e76ab9__8000_00000007.tmp fileName:application base.doc fileType:application/msword
    file is :\tmp\upload_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 Settings\admin\桌面\OrderReporterServiceImp.java - [unknown location]

    原因:忘記了在form表單里將enctype設置成文件上傳格式:enctype="multipart/form-data"

    12--當使用限制文件類型和大小的時候拋出空指針異常

    java.lang.NullPointerExceptiondemo.struts2.action.ValidatFileUploadAction.execute(ValidatFileUploadAction.java:71)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)原因:在ACTION中配置了fileUpload攔截器后忘記了配置默認攔截器:defautlStack。注意當ACTION中配置自己的攔截器后需要顯示配置默認

    攔截器defaultStack


    13--在國際化時候拋空指針異常:

    16:31:12,812 ERROR [jsp]:253 - Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException at java.text.MessageFormat.applyPattern(MessageFormat.java:414)

    at java.text.MessageFormat.<init>(MessageFormat.java:350)
    at com.opensymphony.xwork2.DefaultTextProvider.getText(DefaultTextProvider.java:70)

    原因:忘記了在struts.xml中配置國際化常量,或者在struts.properties中配置全局國際化常量 struts.custom.i18n.resources=globeMessage


    14-- struts action的配置文件加載失敗:

    Unable to load configuration. - result - file:/D:/Java/apache-tomcat-5.5.20/webapps/mysts/WEB-INF/classes/test.xml:10:26

    Caused 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:26
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:609)

    原因:忘記了繼承包struts-default


    15-- struts action 配置文件注意事項:

    1. 別忘記了繼承struts-default默認配置包

    2.如果配置命名空間,一定要以"/"開始,例如:namespace="/test"

    3.每個模塊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' attribute's literal value.

    解決方法:

    經過測試發現,是沒有正確使用tag的原因,這種情況下,正確的寫法應該是,<s:form name="login" method="post" action="login" >

    您是否添加了action這個呢?

    主站蜘蛛池模板: 精品亚洲视频在线| 亚洲AV成人影视在线观看| 亚洲国产成人AV网站| 久久精品免费全国观看国产| 亚洲伦理一区二区| 久久这里只精品国产免费10| 久久夜色精品国产嚕嚕亚洲av| 国产在线观看免费av站| 亚洲线精品一区二区三区影音先锋| 日韩电影免费在线观看网址 | 亚洲不卡视频在线观看| 曰批视频免费30分钟成人| 亚洲日产2021三区在线| 97在线线免费观看视频在线观看 | 极品美女一级毛片免费| 亚洲七七久久精品中文国产| 三年片免费观看大全国语| 久久亚洲精品视频| 久热中文字幕在线精品免费| 亚洲三级在线视频| 国产精品免费视频一区| 免费看一级一级人妻片| 久久精品国产亚洲AV网站| 色影音免费色资源| 亚洲AV色无码乱码在线观看| 亚洲精品综合久久| 99免费视频观看| 亚洲乱理伦片在线观看中字| 亚洲性日韩精品国产一区二区| 国产午夜无码精品免费看| 亚洲国产精品综合久久网各 | 亚洲欧洲自拍拍偷午夜色无码| 一区二区三区福利视频免费观看| 亚洲一级毛片中文字幕| 免费a级毛片无码av| 少妇无码一区二区三区免费| 亚洲日韩精品无码专区加勒比☆| 国产成人精品久久亚洲| 亚洲大片免费观看| 四虎一区二区成人免费影院网址| 亚洲欧洲一区二区|