使用jsf上传文件

时间:2014-12-18 17:01:47

标签: jsf gatling

我用gatling记录了请求

val addFile = exec(jsfPost("request_1", "/mypages/edit/Publication/247307/default?rf_fu_uid=0.7920034590642899")
  .headers(headers_4)
  .header("Content-Type", "multipart/form-data")
  /* some form params */
  .bodyPart(ByteArrayBodyPart("ioWizardView:ioWizardForm:publ_has_file_PUBL_has_FILE", bytes)
  .contentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet").fileName("postgre_50_juel.xlsx").charset("iso-8859-1"))
  .asFormUrlEncoded)    

我尝试将其发送到服务器,但在服务器端我有错误

--hXlZi0Ndw092_ZlvrWTUksxrmiCKDIOma
Content-Disposition: form-data; name="ioWizardView:ioWizardForm:publ_has_file_PUBL_has_FILE";
filename="postgre_50_juel.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=ISO-8859-1
Content-Transfer-Encoding: binary
PK     ! b  ?    h^[Content_Types].xml ?    (?
java.io.CharConversionException: isHexDigit

1 个答案:

答案 0 :(得分:0)

“java.io.CharConversionException:isHexDigit”表示您传递的字节无法使用您设置的字符集正确解码(“”iso-8859-1“”)。

当您计算传递的“字节”时,您可能使用了另一种编码。

如果您没有动态计算上传文件,最好使用RawFileBody而不是ByteArrayBodyPart。

相关问题