URL给参数传递中文值

  • Last update:June 21, 2019
  • 1. 描述

    虽然我们建议模板名称、参数变量名称都用英文,但是对于中国式的复杂报表,参数肯定有中文情况。

    使用 IE 浏览器通过 URL 给参数赋值为中文时,会发现中文值会出现乱码,如下图所示

    222

    2. 问题原因

    因为浏览器编码与服务器编码不一致,导致中文 URL 输入会产生乱码,无法被正常识别。

    3. 解决方案

    通过 URL 给参数赋值一般应用在报表已经集成到项目中,希望点击某个链接将某个值传递给报表;而在浏览器中直接给参数赋值呢,一般是做测试使用的,此时可以将浏览器换成火狐或者谷歌。

    集成到项目中,可以使用 encodeURIComponent 方法,如点击某个链接给 col 赋值为地区,此时可以使用如下方法:

    window.location="http://localhost:8075/webroot/decision/view/report?viewlet=doc/Parameter/DynamicCol/DynamicCol.cpt&col="+encodeURIComponent("中文名称")

    详细的内容可参考 编码转换 章节。


    Attachment List


    Theme: 报表专题
    Already the First
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy