【正文】
flex中的請求交由服務器中的servlet處理,在提交的URL中需要包括servlet名。java上傳文件程序步驟:首先對request和response設置編碼格式,以免產(chǎn)生中文亂碼,特別是request,一旦有亂碼,后臺根本就識別不了了,更別說處理。創(chuàng)建一個工廠對象(DiskFileItemFactory類),用于對磁盤的寫入。再根據(jù)這個工廠對象創(chuàng)建一個上傳對象。該上傳對象會根據(jù)request來解析文件,生成一個ListFileItem,在就是對該List進行循環(huán)處理,通過List中對象的write方法將數(shù)據(jù)寫入磁盤。操作結(jié)束。// Check that we have a file upload request 判斷是否是文件上傳請求boolean isMultipart = (request)。The simplest usage scenario of uploading is the following:1. Uploaded items should be retained in memory as long as they are reasonably small.2. Larger items should be written to a temporary file on disk.3. Very large upload requests should not be permitted.4. The builtin defaults for the maximum size of an item to be retained in memory, the maximum permitted size of an upload request, and the location of temporary files are acceptable.Flex負責前臺界面,Java則負責前臺傳遞過來的請求(即文件上傳請求)。這里只是一個簡單的例子,供大家入門用哈。有關(guān)Flex和Java servlet方面的知識這里就不列出來了,沒有整理,大家自己找資料吧。前提:要從網(wǎng)上下載這兩個jar包。然后在MyEclipse中配置Build Path,將這兩個包包含進去。直接貼代碼吧:Flex代碼,:?xml version= encoding=utf8?s:Application xmlns:fx= xmlns:s=library:// xmlns:mx=library:// minWidth=955 minHeight=600 creationComplete=init()。 s:layout s:BasicL