如何用seam實現檔案上傳

2021-04-12 23:01:26 字數 1863 閱讀 2759

1.  需要兩個seam元件。乙個tomahawk 和slsb用來處理jsf action 的 "backing bean"。

1a. backing bean:

@name("uploadbean")

public class uploadbackingbean

@notnull

public uploadedfile getfile()

}

1b. action 和它的介面檔案 

@stateless

@name("upload")

@interceptors(seaminterceptor.class)

public class uploadaction implements upload

public string upload()

}

@local

public inte***ce upload

2. 如果你想通過facelets訪問tomahawk upload 元件,需要定義乙個tomahawk.taglib.xml 檔案。它應被包含在.war 包的web-inf 目錄。

完整的taglib 定義: http://wiki.apache.org/myfaces-data/attachments/use_facelets_with_tomahawk/attachments/tomahawk.taglib.xml

3. web.xml中,tomahawk 需要的部分:

extensionsfilter

org.apache.myfaces.component.html.util.extensionsfilter

uploadmaxfilesize

100m

uploadthresholdsize

100k

*.seam

facelets.libraries

/web-inf/tomahawk.taglib.xml

4. html可以像這樣: 

5.  最後,把tomahawk.jar 、the commons-file-upload.jar、common-io.jar 打包到ear。當然需要在manifest.mf 檔案中修改class-path。

class-path: jboss-seam.jar commons-fileupload-1.1.jar commons-io-1.2.jar tomahawk.jar

希望有所幫助. regards. marcio endo

下面有附件。檔案是fileupload.zip。它不包含完善的build.xml。不過你可以通過ant -f packaging-build.xml 生成必需的.ear。

例子執行環境:

marcio endo

不必修改manifest 檔案。我已經把全部tomahawk 元件整合了。一會兒我把設定貼出來。

fady matar

alternative fileupload

我已經整合了例子檔案,不需要backing bean ,用seam gen工具建立專案。

arthur marinis

附件:fileupload.zip

1849616 bytes

bq_cui:

這個例子我還沒有測試,應該還不能將檔案上傳資訊儲存到資料庫中。2007-4-27

如何用PHP給上傳的檔案改名

php5現在推薦 files這個超全域性變數陣列來代添 http post files 你想你說的一定是上傳檔案重新命名吧 可以使用 個人認為他們都可以重新命名的,只是改變了檔名罷了,你想想是不是呢 rename 重新命名 copy 複製 upload move file 移動 date 得到當前時...

如何用Git命令上傳檔案或目錄

1.clone 所有資源 git clone 2.add當前操作目錄的以下檔案 git add docx doc zip 3.或者add當前操作目錄下的以下目錄 git add foldname foldname1 foldname2 4.commit並且寫上注釋 git commit m 這裡寫c...

PHP如何實現檔案上傳

php如何實現檔案上傳 1.表單部分允許使用者上傳檔案,在html表單的宣告中要加上乙個上傳的屬性 enctype multipart form data 表單的method必須是post 表單選項max file size隱藏域用於限制上傳檔案大小,它必須放在檔案表單元素前面,單位為位元組。如 複...