问题标签 [params]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
3832 浏览

ruby-on-rails - Rails 中的 Params 对象中的变量符号

我有以下代码:

其中 xxxx 代表男性或女性。基本上表单提交通过一组female_profile[foo]或一个male_profile[foo],我想相应地改变它。假设我有一个可以代替 xxxx 插入的字符串,我如何动态创建这个符号?

谢谢。

0 投票
1 回答
836 浏览

ruby-on-rails - rails routes params 查找表单

我的 Rails 应用程序有点问题。简而言之,它是一个社交网络应用程序,用户可以在其中拥有个人资料、提交内容并可以评论提交内容。

我的路线如下:

因此,当他们查看提交时,URL 看起来像:

http://www.example.com/users_username/2342

数字是类别的 id 号。到现在为止还挺好。当我尝试对提交内容发表评论时,我遇到了麻烦。每个提交页面上都有一个提交评论的表单,如下所示:

控制器看起来像这样:

现在,每次我尝试提交评论时,Rails 都会返回:

基本上,rails 没有使用参数从 URL 中提取 :id,我不知道为什么。提交页面为 URL 中的每个 ID 正确显示,所以我不明白为什么它不为这个表单拉它。如果我明确命名 id(IE Submission.find(2345)),它可以完美运行......那我错过了什么?我只是愚蠢吗?

我的人际关系也建立得很好。

提前致谢。

0 投票
4 回答
13644 浏览

ruby-on-rails - how can I hide params I transmit to a method (like form_for seems to do)?

I've been searching for hours now and haven't found anything that helps.

What I want to do:

I need to call the check_login-Method (as below), which needs parameters.

The point is that these params are sent in the method-call as in the "Redirected to"-line below.


I want to prevent rails from putting the params into the url and pass them hidden instead.

When I send a form created with form_for, there's nothing in the url, so I assume it must be possible.

Please tell me how to do that.


Steps tried

  • I have tried different "html-verbs": get, put, post - no difference. Though the call of check_login is really short the url-with-params shows up in my Console
  • create an instance variable and pass it as param (strange, didn't work either)
  • watch form_for working – without results, got no clue


//edith:
Thanks for all your help so far. Perhaps I didn't specify my problem in enough detail. I've got a text_field in which I enter short commands (experimentally). Its form calls execute in AppController, which in case of login-data performs redirect_to check_login. I don't need to access a webpage, I simply want to run the method. I liked the idea of putting it into :flash, but I'm wondering if there's a "neater" way to do pass the data hidden.

0 投票
1 回答
1284 浏览

java - 编码帖子中使用的参数

我需要将参数编码为我打算发布到网站的 ISOLatin。我正在使用 org.apache.http。图书馆。我的代码如下所示:

谢谢!

0 投票
2 回答
6075 浏览

ruby-on-rails - rails - 在 url 中传递 :params

我又被卡住了一次……又一次我怀疑这是一个愚蠢的语法问题:

我想用我超级简单的搜索表单在 url 中传递 2 个变量。

我期待这样的 URL: http://mydomain/categories/search?search=pdf&os=2 但我得到了这个: http://mydomain/categories/search?search=pdf&os[]=

我认为它应该像这样工作:

......但是,它没有做到......

有谁知道我哪里出错了?

谢谢!

瓦尔

0 投票
2 回答
2803 浏览

ruby - 使用 Sinatra 的多个块参数

我试图让这个 Sinatra GET 请求工作:

我知道您可以获得一个参数来处理块参数:

但是如何在第一个代码块中使用多个块参数?我对其他方法持开放态度。

0 投票
9 回答
20836 浏览

c# - C#:参数关键字与列表

使用 params 关键字与 List 作为某些 c# 函数的输入的优缺点是什么?

主要是性能考虑和其他权衡。

0 投票
3 回答
23228 浏览

c# - 参数 IEnumerableC#

为什么我不能使用带参数的 IEnumerable?这会得到解决吗?我真的希望他们重写旧库以使用泛型......

0 投票
3 回答
4443 浏览

perl - pre($ENV{'QUERY_STRING}) 和 ($cgi->param()) 有什么区别?

对于 perl cgi 脚本,这两者之间有什么区别(技术上)?

0 投票
1 回答
1309 浏览

perl - 即使参数有效,为什么我的 Perl 子例程返回 false?

我正在尝试编写一个函数来验证用户名的字母数字值,如果失败,它应该记录我的自定义错误消息并将 0 返回到被调用的函数而不是死掉:

使用上面的代码,我面临一个问题,比如在成功的情况下它仍然返回 0。任何人都可以在这方面帮助我吗?谁能解释我为什么这样做?