我有以下网址: $url = 'http://mysite.com/?p=welcome&x=1&y=2';
我需要解码它以便header("Location: $url");实际工作.
但是,使用urldecode($url)不起作用,因为它没有解码&- > &因此浏览器被重定向到http://mysite.com/?p=welcome&x=1&y=2失败.
我需要它来解码,使它看起来像: http://mysite.com/?p=welcome&x=1&y=2
我怎么做?
我正在尝试使用xslt设置rss Feed的样式.我想显示存储在Feed中标记中的图像.问题是它被编码为在页面上显示为文本而不是被渲染.以下是字符串的一部分示例.
1).<description>< img src ="http:// buavhw.blu.livefilestore.com/ y1ppCokLxFJSG2cmyPdvg ...
我不得不在上面的字符串中添加额外的编码,以使其在此处正确显示.下面的字符串是我将其直接粘贴到文本框中时的显示方式.
2).<description> <img src ="http:// buavhw.blu.livefilestore.com/ y1ppCokLxFJSG2cmyPdvg ...
如果我从预览窗口再次复制并粘贴它,它只会变成以下字符串.
3).<description> <img src ="http://buavhw.blu.livefilestore.com/y1ppCokLxFJSG2cmyPdvg ...
我有一个带有查询字符串的URL,通过它可以传递一些数据.我想检索服务器端的数据.这个问题的解决方案是什么?
我在这里遇到一个奇怪的问题,但不确定这是不是这个bug.该项目在Spring Framework下运行.
风景:
<form method="GET" action="someUrl.htm" enctype="application/x-www-form-urlencoded" >
<label>Label</label>
<input name="val1" value="${val1}" />
...
<!-- submit button here -->
</form>
Run Code Online (Sandbox Code Playgroud)
控制器mappend someUrl.htm使用SimpleUrlHandlerMapping
<bean id="parameterMethodNameResolver"
class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"> <property name="methodParamNames">
...
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlDecode" value="false" />
<property name="mappings">
<props>
<prop key="**/someUrl.htm">someController</prop>
</props>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我想传递%的val1.但是当我这样做时,下面的代码返回null:
request.getParameter("val1");
Run Code Online (Sandbox Code Playgroud)
catalina.out显示:
警告:参数:字符解码失败.已忽略值为'%'的参数'val1'.
我发现Spring解码查询字符串并request.getQueryString()返回val1=%但不是val1=%25.
如何在这里阻止UrlDecoding?
那是一个错误吗?请注意urlDecode参数设置为false.
任何解决问题的想法,因为我真的需要使用像这样的字符%&=.
这是框架中的错误吗?
我必须在这里使用HttpUtility.UrlDecode.我认为事情是在MVC中自动解码的.
public Thingy[] Get(string id)
{
var actualId = HttpUtility.UrlDecode(id ?? string.Empty);
var result = MakeThingy(actualId );
return result;
}
Run Code Online (Sandbox Code Playgroud)
我应该能够做到这一点......
public Thingy[] Get(string id)
{
var result = MakeThingy(id ?? string.Empty);
return result;
}
Run Code Online (Sandbox Code Playgroud) 我需要对VBScript中的字符串进行URL解码.该字符串可能包含Unicode字符,根据UTF-8编码为多个字节.因此,例如"巴黎%20%E2%86%92%20Z%C3%BCrich"将解码为"巴黎→苏黎世".
为了完成这项工作,我使用了一段代码如下:
Function URLDecode(str)
set list = CreateObject("System.Collections.ArrayList")
strLen = Len(str)
for i = 1 to strLen
sT = mid(str, i, 1)
if sT = "%" then
if i + 2 <= strLen then
list.Add cbyte("&H" & mid(str, i + 1, 2))
i = i + 2
end if
else
list.Add asc(sT)
end if
next
depth = 0
for each by in list.ToArray()
if by and &h80 then
if (by and &h40) = 0 then
if depth = 0 then …Run Code Online (Sandbox Code Playgroud) 我正在尝试从URL中检索值并使用angular JS在我的网页中显示它.我在做什么
1)将整个url保存到变量并将其拆分,以便我可以过滤到我需要的值.
2)但是当有空格时,它显示为%20.我希望这个%20显示为空格本身.
示例:john doe显示为john%20doe
调节器
function InboxController($scope, $http, $cookieStore, $location) {
$scope.single_mail = function()
{
var url = $location.url();
var split_url = url.split('=');
var mess_id = split_url[1];
var from = split_url[2];
var id_value = mess_id.split('&');
var inbox_id = id_value[0];
var from_value = from.split('&');
$scope.inbox_from = from_value[0];
$scope.single_message = [];
$scope.single_message = [];
var single_inbox_mail ="https://phoe.manage.com/app/inbox/message.html?contactid="+conId+"&token="+token+"&id="+inbox_id;
$http.get(single_inbox_mail).success(function(response) {
$scope.single_message = response[0];
});
Run Code Online (Sandbox Code Playgroud)
HTML视图
<div class="page" data-ng-controller="InboxController">
<div class="row" ng-init="single_mail()">
<div class="mail-header row">
<div class="col-md-8">
<h3>{{single_message.subject}}</h3>
<h4>From : <strong>{{inbox_from}}</strong></h4>
</div> …Run Code Online (Sandbox Code Playgroud) 我正在使用awkurldecode一些文字.
如果我将字符串编码到printf语句中,就像printf "%s", "\x3D"正确输出一样=.如果我将整个转义字符串作为变量,则相同.
但是,如果我只有,我3D怎么能追加\x所以printf会打印=而不是\x3D?
我正在使用busybox awk 1.4.2和ashshell.
我不确定SOF是否是最好的问题,但是关于java URLEncoder和URLDecoder.
对于URLEncoder,它具有encode(String, String)第二个参数是要使用的编码名称的方法.如果编码无效,则UnsupportedEncodingException抛出a.它是一个经过检查的异常,因此在调用时必须使用try-catch语句encode().这在使用String编码方面是有意义的......
但是Java内置了Charset类,您可以Charset使用Java的StandardCharsets或Guava的Charsets轻松访问您喜欢的编码对象.这样可以防止需要捕获一个异常,如果您输入encode()正确拼写的编码名称,则该异常将永远不会被抛出.如果没有使用类似方法的能力URLEncoder.encode(String, Charset),我写的代码变得非常难看,因为我需要存储一个额外的String变量来存储编码名称,我有一个非常冗余的try-catch语句,如下所示:
private static final String utf8 = "UTF-8";
...
String msg = ...;
try {
String encodedMsg = URLEncoder.encode(msg, utf8);
...
} catch (UnsupportedEncodingException e) {
// This exception should never happen
System.err.println("Uh oh...");
}
Run Code Online (Sandbox Code Playgroud)
适用的逻辑相同URLDecoder.decode(String, String).
所以因此,我只是想知道,为什么Java的没有URLEncoder.encode(String, Charset),也没有URLDecoder.decode(String, Charset)?Java语言的开发人员有没有计划支持这个?它会把我上面写的多线怪物变成一个更令人愉快的单行,不需要我捕捉一个我知道永远不会发生的例外,除非政府将UTF-8定为犯罪.是否有任何现有的实现或库可以改进URLEncoder和URLDecoder中缺少的功能?我试着在番石榴里寻找东西,却一无所获.
据http://php.net/manual/en/function.urldecode.php,PHP确实urldecode()在$_GET和$_REQUEST(包含$_POST).
但直接调用$_POST已解码?