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

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

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

    posts - 56, comments - 54, trackbacks - 0, articles - 4
       ::  ::  :: 聯系 :: 聚合  :: 管理

    Struts1.0.2中上傳文件功能的Bug

    Posted on 2005-12-05 10:47 Terry的Blog 閱讀(627) 評論(0)  編輯  收藏 所屬分類: java語言

    Struts1.0.2中上傳文件功能的Bug(日文文件名有時不能完整表示)
     
    struts1.0.2中解析"multipart/form-data"型的request時沒有根據request.getCharacterEncoding()的結果來解碼.
    當截取filename時就可能丟失一些字符.比如文件名為"ソウス.xls"

    RequestUtil.java 
        public static void populate(Object bean, String prefix, String suffix,
                                    HttpServletRequest request)
            throws ServletException {
       
            //initialize a MultipartRequestHandler
            MultipartRequestHandler multipart = null;
            String multipartClass = (String)
            request.getAttribute(Action.MULTIPART_KEY);
            request.removeAttribute(Action.MULTIPART_KEY);
            ......
            //在這里取處理MultipartRequest的類
            multipart = (MultipartRequestHandler) Class.forName(multipartClass).newInstance();
            ......
        }
        
        // 自定義一個DiskMultipartRequestHandlerX

        ActionServlet.java
        /**
         * The MultipartRequestHandler class name used for handling
         * multipart form requests.  This is the global default value,
         * the handler can also be set in individual mapping entries
         */
        protected String multipartClass = "org.apache.struts.upload.DiskMultipartRequestHandler";
       
        public class DefaultActionServlet extends ActionServlet {
       
            protected void process(HttpServletRequest request,
                                   HttpServletResponse response) {
                try {
                    String contentType = request.getContentType();
                    String method = request.getMethod();
                   
                    //if this is a multipart request, wrap the HttpServletRequest object
                    //with a MultipartRequestWrapper to keep the process sub-methods
                    //from failing when checking for certain request parameters
                    //for command tokens and cancel button detection
                    if ((contentType != null) && (contentType.startsWith("multipart/form-data"))
                        && (method.equals("POST"))) {
                        //request.getAttribute(Action.MULTIPART_KEY);
                        // 設置處理MultipartRequest的類,也可以在struts-config.xml中設置。
                        request.setAttribute(Action.MULTIPART_KEY, "com.struts.upload.DiskMultipartRequestHandlerX");
                    }
                   

                    request.setCharacterEncoding("Shift_JIS");
                    super.process(request, response);
                  
                } catch(Exception e) {
                    log.error("encode error: ", e);
                }
            }
        }

    這個問題在struts1.1中得到了解決.

    主站蜘蛛池模板: 男女一边摸一边做爽的免费视频 | 国产高清在线精品免费软件| 亚欧乱色国产精品免费视频| 四虎永久成人免费| 亚洲avav天堂av在线不卡| 9久久免费国产精品特黄| 亚洲精品国产自在久久| 一级毛片免费观看不收费| 日韩精品亚洲专区在线观看| 亚洲AV日韩AV永久无码免下载| 四虎影视无码永久免费| AA免费观看的1000部电影| 久久亚洲国产最新网站| 两个人看的www免费视频| 亚洲人成人一区二区三区| 日本免费久久久久久久网站| 亚洲天天做日日做天天看| 免费无遮挡无码视频在线观看 | 亚洲精品无码不卡在线播放HE| 国产vA免费精品高清在线观看| 亚洲乱亚洲乱妇无码麻豆| 久久久国产精品无码免费专区| 午夜dj在线观看免费视频| 亚洲国产成人久久精品动漫| 2021在线永久免费视频| 中文字幕日韩亚洲| 国产精品99久久免费观看| 亚洲免费视频网址| 亚洲免费人成视频观看| 亚洲区日韩精品中文字幕| 亚洲另类激情专区小说图片| 免费一级不卡毛片| 亚洲男同帅GAY片在线观看| 色欲色香天天天综合网站免费| 亚洲人成图片网站| 亚洲日韩在线观看| 中文字幕免费在线| 白白色免费在线视频| 亚洲无删减国产精品一区| 日韩一级免费视频| 亚洲av永久无码精品网址|