2010-05-10 100 views
1
<package name="my-default" extends="struts-default" namespace="/"> 
<interceptors> 
<interceptor-stack name="globalInterceptor"> 
..... 
    <interceptor-ref name="fileUpload"> 
    <param name="maximumSize">1048576</param> 
    <param name="allowedTypes">application/x-rar-compressed</param> 
    </interceptor-ref> 
..... 
</interceptor-stack> 
</interceptors> 
.... 
</struts> 

我想在Struts2其中攔截 「的FileUpload」 挖掘類型.rar程序文件,但是當我定義 「allowedTypes」 「應用程序/ x-RAR壓縮」,這不是哪個沒有工作。什麼是struts2中.rar文件(攔截器「fileUpload」)的「allowedTypes」?

我該如何解決這個問題?

回答

0

MIME類型由您的瀏覽器設置,並且這(特別是.rar文件類型,不像其他人那麼受歡迎)不是完全可見的 - 我懷疑它可能因瀏覽器而異。如果想要安全玩,可以省略allowedTypes選項並在您的操作中以編程方式進行檢查。也許你會希望也(不作爲替代,但作爲補充檢查),以檢查客戶端的文件擴展名,用Javascript。

+0

爲年幫助:)謝謝 – m0z4rt 2010-05-14 03:42:13

1

這些都是允許的類型的值 -

圖像/ GIF,圖像/ JPEG,圖像/ PNG,圖像/ BMP,應用/ MSWORD,文本/無格式,應用/ PDF,應用/ MS-Excel中,應用/vnd.ms-excel,image/bitmap

拉爾和拉鍊不是其中之一。

0

嘗試 <param name="allowedExtensions ">rar</param>