About request. getHeader (& quot; Referer & quot ;)

Source: Internet
Author: User

Let me share with you today, request. getHeader ("Referer") gets the URL link of the last visit, and under what circumstances will it cause problems!
On some pages, how many buttons can be used to jump to action. do? Method = m. However, I use
WarpLoaction ("url"); this links to the past. As a result, I can use the Firefox browser correctly.
Obtain the last accessed page, but cannot obtain it in IE6. Later, I went to Baidu and saw a comment from yige.
Request. getHeader ("Referer") must follow the HTTP protocol to obtain a value, that is, the request must pass <a href = "url"/>
To obtain the value. Of course, you can also submit it through a form. However, if location or <a href = "javascript: window. location ='' "/> is used, the value is not obtained. That's the reason. Hey.

Another problem is garbled. If the request. if the getHeader ("Referer") Link contains a Chinese parameter, garbled characters will appear during the jump. In this case, String keyWords = new String (str. getBytes ("ISO-8859-1"), "GBK"); to encode conversion! However, if the request is not passed. keyWords = new String (str. getBytes ("ISO-8859-1"), "GBK"); to encode the conversion, it will appear garbled, I am here to share how I solve, first of all, I use str. matches ("[\ u4E00-\ u9FA5] +") to determine whether the string contains Chinese characters. If there is no Chinese character, it is garbled characters, numbers, English letters, or other symbols, then we will perform encoding conversion. If it is Chinese, no encoding conversion will be performed!

Related Article

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.