如何获取url中传递的参数值?例如我的网址是/forgot-password?email=testing@example.com&token=fb49d692186dd4744af50446fad2f031
我想获取电子邮件和令牌的值。我从文档中找到的只是关于作为参数值的段,该参数值是从路线设置的,/user/:id这对于我的情况来说是不同的用法。
我很难制作 URL 来使用过滤器获取数据。后端 REST api 是在 .Net 中构建的。过滤项目的 url 格式如下:
BASE_URL/ENDPOINT?技术=some-id&Complexities=0&Complexities=1&page=1&pageSize=3
技术和复杂性可以使用不同的值重复 x 次。
RTK Query 提供了查询功能,但它没有按照我需要的方式构建 url。
export const apiService = createApi({
reducerPath: 'apiService',
baseQuery: fetchBaseQuery({ baseUrl: BASE_URL }),
endpoints: (build) => ({
getAllQuizzes: build.query<ApiResponse, QueryProps>({
query: ({ Technologies, Complexities, page, pageSize }) => {
return ({
url: ENDPOINT,
params: {
Technologies,
Complexities,
page,
pageSize,
}
})
},
}),
}),
});Run Code Online (Sandbox Code Playgroud)
我使用 mui 异步自动完成组件来选择多个过滤器。有任何想法吗?
使用URL访问:
http://127.0.0.1/test.jsp?action=test&abc
Run Code Online (Sandbox Code Playgroud)
要么
http://127.0.0.1/test.jsp?abc
Run Code Online (Sandbox Code Playgroud)
怎么才能得到字符串"abc"?
感谢帮助 :)
我试图将参数传递给python cgi脚本,此参数包含加号运算符.
/cgi-bin/test.py?input=print%20"%20"%20"%20%20-+-\"
Run Code Online (Sandbox Code Playgroud)
python cgi脚本很简单:
#!/usr/bin/python -w
import cgi
fs = cgi.FieldStorage()
print "Content-type: text/plain\n"
strE=fs.getvalue("input")
print strE
Run Code Online (Sandbox Code Playgroud)
我的输出是:
print " " " - -\"
Run Code Online (Sandbox Code Playgroud)
我不明白为什么'+'加运算符被空格替换,我怎么可以通过'+'加运算符?
编辑
@Tom Anderson回答了我的问题,我想再提一下我的问题.
我有一个java脚本函数调用获取带参数的url:
<script type="text/javascript">
function PostContentEditable(editableId,targetOutput)
{
var texthtml = document.getElementById(editableId).innerHTML
var tmp = document.createElement("DIV");
tmp.innerHTML = texthtml ;
var str= tmp.textContent||tmp.innerText;
var xmlhttp;
if (str.length == 0){
document.getElementById(targetOutput).innerHTML = "";
return;
}
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById(targetOutput).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","../cgi-bin/exercise.py?input="+str,true);
xmlhttp.send();
} …Run Code Online (Sandbox Code Playgroud) 我在网址下面。
http://localhost:8080/servlet?user=John&message=hai&hello&recipient=scott
Run Code Online (Sandbox Code Playgroud)
在上面的 url 中,我有 3 个请求参数,如下所示。
user=John
message=hai&hello
recipient=scott
Run Code Online (Sandbox Code Playgroud)
这里的问题在于message请求参数的值。因为这里它的值包含符号 (&)。当我尝试时,我request.getParameter("message")只会得到hai但不会hai&hello。我该如何解决这个问题?
谢谢!
我在Windows机器上,使用标准命令行工具并使用PhantomJS和修改后的rasterize.js代码。我遇到的问题是当我传递url时http://time.com/3274245/e-cigarettes-debate/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+time/topstories+(TIME:+Top+Stories)。我已经重定向了StandardOutput和StandardError和,这就是上面的URL所提供的。
标准输出
Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]
paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"
Run Code Online (Sandbox Code Playgroud)
标准错误
'utm_source' is not recognized as an internal or external command,
operable program or batch file.
'utm_medium' is not recognized as an internal or external command,
operable program or batch file.
'utm_campaign' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
所以问题是,有什么办法可以解决网址中的参数问题?
请让我知道是否缺少任何信息,或者是否需要澄清。
我将在rasterize.js下面添加我的修改内容。
var page = …Run Code Online (Sandbox Code Playgroud) 问题:我无法在中间件中找到{id}参数.我的中间件需要获取{id}参数,以验证Auth :: user()是否是指定组的所有者.
请求示例:groups/admin/open/4 - >将打开第4组.
是)我有的:
路线:
Route::post('groups/admin/open/{id}', 'GroupController@opengroup')->middleware(['auth','owner']);
Run Code Online (Sandbox Code Playgroud)
我的中间件('所有者')仍然是空的.
我尝试了什么:1.在函数中添加$ id参数(就像在控制器中一样),如下所示:
public function handle($request, /* Added -> */ $id, Closure $next)
{
dd(Input::get('id'));
return $next($request);
}
Run Code Online (Sandbox Code Playgroud)
这会返回一个错误:
Argument 3 passed to App\Http\Middleware\RedirectIfNotOwner::handle() must be an instance of Closure, none given
Run Code Online (Sandbox Code Playgroud)
最后,$ id的不同位置会导致错误:
Missing argument 3 for App\Http\Middleware\RedirectIfNotOwner::handle()
Run Code Online (Sandbox Code Playgroud)
我试过的2:我想过要改变我的网址
请求示例:groups/admin/open?groupparam = 4
并使用
Input::get('groupparam');
Run Code Online (Sandbox Code Playgroud)
但这迫使我改变我的控制器等.这仍然是一个选择.
问的理由:此外我相信Laravel也有能力在中间件中检索{id} params,非常漂亮.我只是不知道如何.
你能帮助我吗?
谢谢,
Eltyer
在我的URLconf中,我有以下url(login内置登录视图功能django.contrib.auth.views):
url(r'^login/', login, name='login', kwargs={
'template_name': 'topspots/login.html',
'redirect_field_name': 'next',
})
Run Code Online (Sandbox Code Playgroud)
然后在我的模板中,在网站上所有页面上的导航栏中,我有以下登录链接:
<li><a href="{% url 'login' %}?next={{ request.get_full_path }}">Log in</a></li>
Run Code Online (Sandbox Code Playgroud)
当我从例如搜索结果页面访问登录页面时,我在地址栏中获取的URL是这样的:
http://localhost:8000/login/?next=/spots/search/?search_query=South+Oak+Park%2C+KCMO%2C+MO%2C+United+States&searchtype=default&latitude=38.97600750000001&longitude=-94.58623399999999
Run Code Online (Sandbox Code Playgroud)
这似乎对我来说(注意longitude和latitude参数),因为登录后,我想被重定向到
http://localhost:8000/spots/search/?search_query=South+Oak+Park%2C+KCMO%2C+MO%2C+United+States&searchtype=default&latitude=38.97600750000001&longitude=-94.58623399999999
Run Code Online (Sandbox Code Playgroud)
即next路径.但是,从登录视图中,最终的值{{ next }}就是/spots/search/?search_query=South Oak Park, KCMO, MO, United States.换句话说,除了第一个参数之外的所有参数都已被剥离.我无法确定这些参数被切断的时间/地点/原因.这是Django正在做的事情,还是源于我的错误?如果它是Django,我相信它有充分的理由,但如果只是我做错了什么,我想解决它.有什么建议?谢谢!
在我的快递应用程序中,我有一个路由器在听api/shorten/:
router.get('api/shorten/:longUrl', function(req, res, next) {
console.log(req.params.longUrl);
}
Run Code Online (Sandbox Code Playgroud)
当我使用类似的东西:
http://localhost:3000/api/shorten/www.udemy.com
Run Code Online (Sandbox Code Playgroud)
我得到的www.udemy.com是我所期望的.
但是当我使用时:
http://localhost:3000/api/shorten/http://www.udemy.com
Run Code Online (Sandbox Code Playgroud)
我收到404错误.
http://www.udemy.com当我访问时,我想得到req.params.parameter.
如何从服务工作者获取带有参数的页面URL?
我试过了,self.registration.scope但不包括参数.
url-parameters ×10
javascript ×4
java ×2
python ×2
url ×2
cgi ×1
django ×1
express ×1
jsp ×1
laravel ×1
laravel-5 ×1
material-ui ×1
middleware ×1
node.js ×1
phantomjs ×1
php ×1
reactjs ×1
routing ×1
rtk-query ×1
strapi ×1
url-parsing ×1
urlencode ×1