标签: urlencode

Drupal url编码

我无法正确编码URL数据.使用以下代码:

$redirect = drupal_urlencode("user/register?destination=/node/1");
drupal_goto( $redirect );
Run Code Online (Sandbox Code Playgroud)

但是,我的浏览器测试中出现的URL如下:

http://testsite.com/user/register%253Fdestination%253D/node/1
Run Code Online (Sandbox Code Playgroud)

我以为使用drupal_urlencode函数应该解决这个编码问题.有人可以建议一种方法来解决这个问题吗?

drupal urlencode drupal-6

6
推荐指数
1
解决办法
6481
查看次数

Thymeleaf:在 thymeleaf 中创建动态 URL 查询字符串

我是 thymeleaf 的新手,我想使用 thymeleaf url 创建动态查询字符串。对于分页,我使用通用片段并在所有页面中包含片段。所有页面都有搜索选项,搜索时也需要分页。因此,我们需要在分页中传递动态查询字符串作为搜索条件。但是当我动态创建查询字符串时,URL 编码特殊字符,如=&。以下是我的代码

<!-- Pagination Bar -->
<div th:fragment='paginationbar(searchArguments)'>
  <div class='pagination pagination-centered'>
    <ul>
      <li th:class="${page.firstPage}? 'disabled' : ''">
        <span th:if='${page.firstPage}'> First</span>
        <a th:if='${not page.firstPage}' th:href='@{${page.url}(page=0,size=${page.size},${searchArguments})}'>First</a>
      </li>
      <li th:class="${page.hasPreviousPage}? '' : 'disabled'">
        <span th:if='${not page.hasPreviousPage}'>&lt;&lt;</span>
        <a th:if='${page.hasPreviousPage}' th:href='@{${page.url}(page=${page.currentNumber - 2},size=${page.size},${searchArguments})}' title='Go to previous page'>&lt;&lt;</a>
      </li>
       <li th:each='item : ${page.items}' th:class="${item.current}? 'active' : ''">
        <span th:if='${item.current}' th:text='${item.number}'>1</span>
        <a th:if='${not item.current}' th:href='@{${page.url}(page=${item.number - 1},size=${page.size},${searchArguments})}'><span th:text='${item.number}'>1</span></a>
      </li> 
      <li th:class="${page.hasNextPage}? '' : 'disabled'">
        <span th:if='${not page.hasNextPage}'>&gt;&gt;</span>
        <a …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc urlencode thymeleaf

6
推荐指数
1
解决办法
9791
查看次数

RestSharp - 数组作为查询字符串参数

我无法将数组(int 数组)作为查询字符串参数传递给 RestSharp 客户端

var client = new RestClient(baseUrl);
client.Authenticator = new HttpBasicAuthenticator(username, password);

var request = new RestRequest(_endpoint, Method.GET);
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("contenttype", "application/json; charset=utf-8");
            request.AddHeader("Accept", "text/html, application/xhtml+xml, image/jxr, */*");


//i tried with
request.AddParameter("messageIds", "[1,2,3]");
or
request.AddParameter("messageIds", new int[] {1,2,3} );
or
request.AddQueryParameter("messageIds", "[1,2,3]");
or
request.AddQueryParameter("messageIds", new int[] {1,2,3} );
Run Code Online (Sandbox Code Playgroud)

我认为问题与参数的 UrlEncoding 有关

如果我使用“new int[] {1,2,3}”(AddParameter 和 AddQueryParameter)传递值,则 url 的构建方式如下:

ResponseUri = {https://demo.xxxxxxxx.com:8181/ws/messages/zippedMessages?messageIds=System.Int32[]}
Run Code Online (Sandbox Code Playgroud)

如果我将值作为字符串“[1,2,3]”(AddParameter 和 AddQueryParameter)传递,则 url 的构建方式如下:

ResponseUri = {https://demo.xxxxxxxx.com:8181/ws/messages/zippedMessages?messageIds=[1%2C2%2C3]}
Run Code Online (Sandbox Code Playgroud)

相反,工作网址应该是:

ResponseUri = {https://demo.xxxxxxxx.com:8181/ws/messages/zippedMessages?messageIds=%5B1,2,3%5D}
Run Code Online (Sandbox Code Playgroud)

或者至少:

ResponseUri = {https://demo.xxxxxxxx.com:8181/ws/messages/zippedMessages?messageIds=[1,2,3]}
Run Code Online (Sandbox Code Playgroud)

“AddParameter”方法对逗号进行编码,但不对 …

c# urlencode url-encoding restsharp asp.net-web-api

6
推荐指数
1
解决办法
1万
查看次数

在查询字符串中使用逗号可能会产生副作用吗?

我想,在 URL 查询字符串值中使用,但它是保留字符。然而,现在我们可以看到许多电子商务网站都提供了大量逗号查询字符串网址。

当我们在查询字符串中使用时我们会考虑什么,?是否应该像%2c往常一样进行编码?

请注意,我的服务器端框架是 ASP.NET WebApi、dJango 和 Node.js。

url urlencode rfc3986 query-string

6
推荐指数
1
解决办法
6658
查看次数

React 抛出 URIError:这可能是由无效的百分比编码引起的

正在使用react,然后遇到了这样的问题

  Uncaught URIError: This is likely caused by an invalid percent-encoding
Run Code Online (Sandbox Code Playgroud)

我目前正在使用新闻 API,一些文章可能包括%. 我的整个应用程序依赖于在网址中显示新闻文章名称,因为我使用this.props.match.params.id

我尝试在网上寻找解决方案,但大多数人都不清楚如何解决这个确切的问题。

有一个简单的解决方法吗?

router urlencode reactjs

6
推荐指数
1
解决办法
4243
查看次数

如何解码包含阿拉伯字符的(百分比编码 URL)?

我想转换所有语言的百分比编码 URL,但 vb6 仅支持英语。

我已经测试了以下代码。但它只能转换英文字符:

Private Sub Form_Load()
    THE_ARABIC_URL = "%D8%AF%D8%B4%D9%85%D9%86%DB%8C+%D8%AF%D8%B1+%D8%A7%D8%B9%D9%85%D8%A7%D9%82-2019-12-09+01%3A09%3A00"
    MsgBox URLDecode(THE_ARABIC_URL)
End Sub

Private Function URLDecode(ByVal txt As String) As String
    Dim txt_len As Integer
    Dim i As Integer
    Dim ch As String
    Dim digits As String
    Dim result As String

    result = ""
    txt_len = Len(txt)
    i = 1
    Do While i <= txt_len
        ' Examine the next character.
        ch = Mid$(txt, i, 1)
        If ch = "+" Then
            ' Convert to space character.
            result = result …
Run Code Online (Sandbox Code Playgroud)

vb6 urlencode utf-8

6
推荐指数
1
解决办法
476
查看次数

用加号解码字符串

使用 ASP.NET Core 我收到以下令牌(简化):

String token = "Z%2F3+3Q==";
Run Code Online (Sandbox Code Playgroud)

/是使用编码%2F。我从使用 Angular 在客户端上调用的 URL 收到了令牌。

我尝试使用以下方法解码令牌:

HttpUtility.UrlDecode(token)
Run Code Online (Sandbox Code Playgroud)

或者

WebUtility.UrlDecode(token)
Run Code Online (Sandbox Code Playgroud)

在这两种情况下%2F,都由/我想要的+代替,但由我不想要的空格代替。

我如何解码字符串?

更新

客户端应用程序正在发送编码的令牌:

Z%2F3%2B3Q%3D%3D;
Run Code Online (Sandbox Code Playgroud)

但是,不知何故,似乎令牌在以下操作中:

[HttpPut("account/verify/{userId}/{token}")]
public async Task<IActionResult> VerityEmailAddress([FromRoute]AccountEmailVerifyModel model) {
}
Run Code Online (Sandbox Code Playgroud)

转化为:

Z%2F3+3Q==
Run Code Online (Sandbox Code Playgroud)

所以+=被解码,但/不是。

c# urlencode asp.net-routing asp.net-core asp.net-core-3.1

6
推荐指数
1
解决办法
1765
查看次数

URL编码URL

是否有一种.NET编码方法可用于编码要在URL参数中传递的URL?

比如说我有:

url_of_interest = "http://asdf.asdf/asdf.htm"

我想在上传到网络应用程序时将其作为一(1)个URL表单参数包含在内:

http://mywebservice/upload?url=<<encoded URL here>>

.net url urlencode

5
推荐指数
1
解决办法
2167
查看次数

PHP的URL编码问题

我使用用户用Rawurlencode()编码的令牌发送有关用户激活的html电子邮件。

所以-链接显示在电子邮件中,如下所示:

<a href="http://site.com/auth?action=confirmActivation&amp;user=79&amp;token=zlKoFo%22f%27g%3FtUb%27%29Z~L1%25zKh%5EG%23_Aj%5Ckbbbd4fdb9121b50f643f12c937ab1c03d5f09861" target="_blank">Click here to activate your account</a>
Run Code Online (Sandbox Code Playgroud)

但是,当我单击此链接时,我的页面网址看起来像这样:

http://site.com/auth?action=confirmActivation&user=79&token=zlKoFo%22f%27g%3FtUb%27%29Z~L1%25zKh^G%23_Aj%5Ckbbbd4fdb9121b50f643f12c937ab1c03d5f09861
Run Code Online (Sandbox Code Playgroud)

所以-之前的令牌(这是它在我的电子邮件中的显示方式):

zlKoFo%22f%27g%3FtUb%27%29Z~L1%25zKh%5EG%23_Aj%5Ckbbbd4fdb9121b50f643f12c937ab1c03d5f09861
Run Code Online (Sandbox Code Playgroud)

之后的令牌:

zlKoFo%22f%27g%3FtUb%27%29Z~L1%25zKh^G%23_Aj%5Ckbbbd4fdb9121b50f643f12c937ab1c03d5f09861
Run Code Online (Sandbox Code Playgroud)

看起来我的浏览器单击时会自动进行一些转换吗?为什么?

php urlencode rawurl

5
推荐指数
1
解决办法
596
查看次数

使用Java在URL中编码参数值

我需要在URL中编码参数值.如果我使用以下内容:

URLEncoder.encode(url, "UTF-8");
Run Code Online (Sandbox Code Playgroud)

对于这样的URL: http://localhost:8080/...

它将编码"://"等.我需要的是仅对从所有URL字符串开始的参数值进行编码.所以在这种情况下:

HTTP://本地主机/ Q =等等&d =嗒嗒

我想只编码2个参数值中的"blah"(当然是n个参数).

你最好的方法是什么?

谢谢

随机化

java url urlencode

5
推荐指数
1
解决办法
8829
查看次数