About the href parameter between JSP (Chinese) garbled problem

Source: Internet
Author: User

There are href values in the a.jsp.

<a href=\ "6.jsp?param=" +rs.getstring (2) + "\" > "

Use in b.jsp

<% request.setcharacterencoding ("Utf-8");%>

<%=request.getparameter ("param")%>

Get value, run debug find is a bunch of garbled

At first I thought it was the JSP overall encoding method is not correct, so the following changes:

Change the beginning of the b.jsp to

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "Utf-8"%>

Insert <meta http-equiv= "Content-type" content= "text/html in front of title; Charset=utf-8 ">

Then run the debug

Find it or

I have added a few Chinese output in HTML, run debugging found that the Chinese can be very good output only the value of the parameter is garbled

This is not a JSP overall encoding format problem, but b.jsp when the value is not read in the wrong format, so I made the following changes:

<% request.setcharacterencoding ("Utf-8");%>

<%string name=new String (request.getparameter ("param"). GetBytes ("Iso-8859-1"), "Utf-8");
OUT.PRINTLN (name);
%>

Run debug Discovery to display Chinese very well

About the href parameter between JSP (Chinese) garbled problem

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.