Use JScript to make UTF-8 encoding for form data (apocide)

xiaoxiao2021-03-06  41

If you need to reprint, please indicate the source and the author. Thank you QQ: 221704MSN: Flyly@yeah.netemail: zhangfl@sports.cn code: for (i = 0; i <_input.length; i ) {i (_input [i] .type == "text") {_Input [i] .Value = encodeuri (_input [i] .value);}} for (i = 0; i <_text.length; i ) {_text [i] .value = encodeuri (_text [i] .value ); UPLOADFORM.Action = "UploadAction.do"; //uploadform.action="testupload.jsp "; UPLOADBEGIN (); UPLOADM.SUBMIT (); First encode the data in the form. Encodeurl The encoding that is converted from this method is UTF-8. Then in the background of the background in the uploader to decode IF (item.isformfield ()) {Field.Add (item.getstring (), "UTF- 8 "));} Ask me why I do this? I am very depressed. In an uploaded program. The Field data submitted in the form has become garbled (???) when receiving it in the background. I have tried the filter and the way to use new string. (Other form commit programs do not appear garbled problems. My page to the database is GB2312 encoding, including filters). I think there are two kinds. This may happen: First, WebLogic's own data I have submitted to me. I don't know what code did. There is also a possibility that the fileupload is encoded inside the JAR package. But the garbled problem is just a platform that appears in Liunx. Under the helplessness, I had to make UTF-8 encoding before submission. I didn't expect garbled problems. But I still don't know why it will cause this situation. And Java cannot encode data prior to submission. Especially in the field of the field, it is not determined by JScript, and the program is not the most ideal. Because the user will see the Field data in that time submitted to UTF- 8. The user may feel is not very friendly. The solution is to use the Hidden box to submit the data.

转载请注明原文地址:https://www.9cbs.com/read-78811.html

New Post(0)