Le Lundi 12 Septembre 2005 16:36, Letícia Álvares Barbalho a écrit :
> I did what you suggested and changed from byte[] to String, leaving to 
> conversion to hibernate's level. It did solve the problem, thank you.
> 
> But I'm wondering here... I still got a problem with the charset, don't I?
> 

Well if String is correct in form, you don't have charset problems in the struts
part (decoded ok from browser's POST to ActionForm). However, am not sure
struts handle automatic conversion from String to byte[]. When your action 
forms is filled, 
here is what happens in non-fileupload forms:
- Browser send form field in a specific encoding.
- Servlet container or commons-fileupload decodes submitted datas and convert 
them to string parameters
- Struts take all submited parameters and uses the beanutils populate() method 
to fill ActionForm
- For each parameter, populate tries to convert the String to the appropriate 
Setter parameter using converters
- In the case of a setXXX(byte[]) signature, the ByteArrayConverter is used.

As far as i can see in this converter source, it's purpose is to convert a 
string like "58,107,24,89" into byte[] {58,107,24,89}
which is not what you want i think.

Why i suggested you to explicitly specify the charset used in String to byte[] 
is because you are storing text in blob on your database, 
that means you must have decided when designed the database, which charset you 
wanted to use (i assumed utf-8). 
You must remain consistent in your various byte[]<->String conversion to this 
blob field.
I suggested UTF-8, but maybe some other thing might be more suitable for you.

Anyway, once you have decided a charset for your blob, stick with it.

-- 
David Delbecq
Royal Meteorological Institute of Belgium

-
Is there life after /sbin/halt -p?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to