Java converts the Chinese characters of parameters passed by URLs into % Percent signs. garbled characters are submitted by URLs.

Source: Internet
Author: User
The following code outputs the URL

Http: // localhost: 8080/news/helloservlet? Hello = % E5 % A4 % A7 % E5 % AE % B6 % E5 % a5 % BD & test = % E5 % A4 % A7 % E5 % AE % B6 % E5 % a5 % BD

HTML code

  1. <Body>
  2. <C: URLValue = "http: // localhost: 8080/news/helloservlet" Var = "url">
  3. <C: ParamName = "hello" value = "$ {Hello }"/>
  4. <C: ParamName = "test" value = "$ {Hello }"/>
  5. </C: URL>
  6. <Href = "<C: Out
    Value = "$ {URL }"/>">$ {Hello}</A>
  7. </Body>
<Body> <C: URL value = "http: // localhost: 8080/news/helloservlet" Var = "url"> <C: param name = "hello" value = "$ {Hello}"/> <C: Param name = "test" value = "$ {Hello}"/> </C: URL> <a href = "<C: Out value =" $ {URL} "/>" >$ {Hello} </a> </body>

<C: URL value = "http: // localhost: 8080/news/helloservlet" Var = "url">
The value in is the submitted URL, and VaR is the URL
<C: Param name = "hello" value = "$ {Hello}"/> indicates the name referenced below. For example, $ {Hello} indicates a static value, that is, the hello in $ {Hello} is displayed, but will be converted to % Percent form to avoid garbled characters when the URL is submitted.

This setting also requires setting urlencoder = "urf-8" in Tomcat/CONF/server. xml"

In addition to the above method, you can also use the following method: pageactionsearch. Action? Resourcesname = <% = java.net. urlencoder. encode ("Mold", "UTF-8") %>

Black hair: http://heisetoufa.iteye.com/

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.