Garbled problem in Javaweb (written on first contact)

Source: Internet
Author: User
The problem of garbled characters in Javaweb

In the first contact Javaweb encountered garbled problem, the following is the solution I have encountered these problems

1. 页面乱码(jsp)        1. 在页面最前方加上    <%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>2. 读取数据时乱码 (servlet)    1. 在request.getParameter("name");前面加上    request.setCharacterEncoding("utf-8");3. 返回数据时乱码 (servlet)     1. 在response.getWriter().print(content);前加上           response.setHeader("Content-type", "text/html;charset=UTF-8");          response.setCharacterEncoding("UTF-8");                        
Note: The above solution is the solution I encountered when the problem, if it does not work or if there are other circumstances, can refer to http://blog.csdn.net/chenghui0317/article/details/10299103, Write the situation quite a lot of this article for the original, if you need to reprint please specify http://www.cnblogs.com/zhuchenglin/p/8098064.html

Garbled problem in Javaweb (written on first contact)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.