[jboss-user] [JBoss Seam] - bug with <s:upload> tag?encoding problem.
liulei1984
do-not-reply at jboss.com
Fri Jun 1 05:34:04 EDT 2007
I use <s:upload> tag to upload one file,whose name contains some Chinese charaters.
something interesting happens.
Our project's encoding is set to be UTF-8.
My partner deploys the project in simplified Chinese windows xp whose local encoding is GBK.When he upload one file,whose name contains some Chinese charaters,he get the file name unrecognised in the program.
While I deploy the project in the ubuntu7.04,whose local encoding is UTF-8.I just do the same things,but everything is fine.
The <s:upload> tag that we use as below
<s:fileUpload data="#{attachment.data}" contentType="#{attachment.contentType}" fileName="#{attachment.name}" style="width:100;" />
We debug into the source code,find that when the request reach org.jboss.seam.web.MultipartRequest.parseRequest() method
,the charator is aready unrecognised.
Below is the code which seams to have some bug.
case HEADERS:
| {
| if (checkSequence(buffer, i, CR_LF))
| {
| parseParams(new String(buffer, pos, i - pos - 1), ";", headers);
We modify the code to be
if(encoding==null)
| parseParams(new String(buffer, pos, i - pos - 1), ";", headers);
| else
| parseParams(new String(buffer, pos, i - pos - 1,encoding), ";", headers);
Now both in windows xp and ubuntu,we get the file name correctly.
I suppose what I find to be useful with others who do love Seam.
Thank you.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050433#4050433
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050433
More information about the jboss-user
mailing list