查询带有特殊字符的字符串 [英] Query strings with special characters

查看:32
本文介绍了查询带有特殊字符的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何传递带有特殊字符的查询字符串?

How I can pass a query string with special characters?

例如我需要传递&"在我的查询字符串中如下:

For example I need to pass "&" inside my query string as below:

../solrresults.asp?mode=search&data=M & S

推荐答案

使用Server.UrlEncode:

URLEncode 转换字符如下:空格 ( ) 转换为加号 (+).非字母数字字符转义为十六进制表示.

URLEncode converts characters as follows: Spaces ( ) are converted to plus signs (+). Non-alphanumeric characters are escaped to their hexadecimal representation.

这样使用;

<a href="page2.asp?name=<%= Server.URLEncode(sName) %>">here</a>

这篇关于查询带有特殊字符的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆