【问题标题】:Error Redirection to restful with special chars错误重定向到带有特殊字符的restful
【发布时间】:2013-11-23 10:14:22
【问题描述】:

当我使用 GET 方法重定向时 $uid=urlencode($uid); 标头(位置:“http://www.example.com/teldom.me.jersey/index.html?userid=$uid&lang=$lang”);'

在 tomcat 中运行带有 url 编码特殊字符的 java restful 服务,浏览器显示:

The requested URL /teldom.me.jersey/rest/conf/EBo6Fp3Od00urp6TIF/3gGcrsg== was not found on this server

Apache 错误日志

[Sat Nov 23 00:13:02 2013] [error] [client xx.yy.65.87] File does not exist: /home/bmil/Dokumenti/webapps/cdn-cgi, referer: http://www.example.com/teldom.me.jersey/index.html?userid=EBo6Fp3Od00urp6TIF%2F3gGcrsg%3D%3D

在 javascript 中,我使用 ajax 请求发送到 restful 服务

http('POST', submitTo, ajax_response, document.form1); 

这是一个用于 AJAX 的 ColdFusion API。 (v 2.6.0)

问题是当 ajax 向 Tomcat 发送带有特殊 html 字符 %2F 的请求时

以下来自tomcat localhost访问日志文件:

xx.yy.65.87 - - [23/Nov/2013:23:17:14 +0100] "GET /teldom.me.jersey/index.html?userid=EBo6Fp3Od00urp6TIF%2F3gGcrsg%3D%3D&lang= HTTP/1.1" 304 -

xx.yy.65.87 - - [23/Nov/2013:23:09:38 +0100] "POST /teldom.me.jersey/rest/conf/E6iKbMC8jTFz4JifHDdqogj3?nocache=1385244552675 HTTP/1.1" 200 288
8

【问题讨论】:

    标签: apache get url-encoding


    【解决方案1】:

    解决了!

     $find_entities = array("/","&", "?");
     if(strpos($id, $find_entities) !== false)
     {
       $uid=urlencode ($uid);
       $uid=urlencode ($uid);
     } else {
          $uid=urlencode ($uid);
     }
    
      header("Location: http://www.example.com/teldom.me.jersey/index.html?userid=$uid"); 
    

    【讨论】:

      猜你喜欢
      • 2012-02-18
      • 2019-01-05
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      • 2018-05-12
      • 2012-06-02
      • 1970-01-01
      • 2018-05-15
      相关资源
      最近更新 更多