A conversion method for javajsp garbled

xiaoxiao2021-03-06  145

In fact, garbled issues have confused many people. There are many articles on the Internet to introduce garbled processing issues.

Many people find it from the Internet to solve the problem, they can still solve it. It is often no medication.

In JSP, I am now known that there are three reasons for the emergence of Chinese garbled. This can be used for the disease. 1. jSP's ContentType setting <% @ page contenttype = "text / html; charSet = GB2312"%>

2. One is that there is no good support in some classes in some packages. For example, I have just used a package that is uploaded, this package is not good for Chinese support, what is the Chinese displayed in the page? ? ? ? ? ? ? . Later, when I took the data removed from this package, I used new string (file_item.getname (). GetBytes ("ISO8859-1"), "GBK")) solves the problem. Such as: <% @ Page ContentType = "Text / HTML; Charset = GBK" Language = "Java" Import = "Java.SQL. *" ErrorPage = ""%> <% @ page import = "org.apache.commons. fileupload.DiskFileUpload, org.apache.commons.fileupload.FileItem "%> <% if (" POST ".equalsIgnoreCase (request.getMethod ()) && request.getContentType (). startsWith (" multipart / form-data ")) {DiskFileUpload (); java.util.list files = upload.parsequest (request); // get a form fileITEM file_Item; for (int i = 0; i >

3. Database data itself is garbled.

Recommend a way here - the method of getBytes ()

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

New Post(0)