我们正在使用第三方Web服务将POSTS多部分数据(文件)发回给我们.但它也通过网址传递额外的参数 http://ourdomain.com/theposturl?extra=good
'filename'对象:filename和:二进制数据的tempfile是params []
但是我们如何从网址中获得"好"呢?
post /theposturl
puts params.inspect # this shows a hash with filename,
# :filename and :tempfile as expected
extra_param = ??????[:extra] # but what lets us 'read' the ?extra=good off the url
end
Run Code Online (Sandbox Code Playgroud) 您好所有我想知道如何使用state.go stateParams或在两个不同页面之间返回AngularJS的上一页,但是我尝试了此操作,但变量为空:
$ctrl.next = function(){
$state.go('modiffili', {object:'test'});
};
Run Code Online (Sandbox Code Playgroud)
这是我第二页的控制器:
(function (angular) {
'use strict';
modiffiliCtrl.$inject=['$state','$stateParams'];
function modiffiliCtrl($state,$stateParams) {
var $ctrl = this;
console.log('modiffiliController');
console.log($state.params.object);
$ctrl.retour = function () {
$state.go('^');
}
Run Code Online (Sandbox Code Playgroud)
我不能使用rootScope。谢谢你帮我!
我想根据条件的结果应用具有不同参数的模板.像这样的东西:
<xsl:choose>
<xsl:when test="@attribute1">
<xsl:apply-templates select='.' mode='custom_template'>
<xsl:with-param name="attribute_name" tunnel="yes">Attribute no. 1</xsl:with-param>
<xsl:with-param name="attribute_value" tunnel="yes"><xsl:value-of select="@attribute1"/></xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="@attribute2">
<xsl:apply-templates select='.' mode='custom_template'>
<xsl:with-param name="attribute_name" tunnel="yes">Attribute no. 2</xsl:with-param>
<xsl:with-param name="attribute_value" tunnel="yes"><xsl:value-of select="@attribute1"/></xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select='.' mode='custom_template'>
<xsl:with-param name="attribute_name" tunnel="yes">Error</xsl:with-param>
<xsl:with-param name="attribute_value" tunnel="yes">No matching attribute </xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
Run Code Online (Sandbox Code Playgroud)
首先,我怀疑这可以通过更好,更好的方式解决.(我是XSLT的新手,所以请提出改进并原谅膨胀的代码.)
现在提出一个问题:我怎样才能根据这个条件设置参数,仍然在一个xsl:apply-templates?我试图xsl:choose用xsl:apply-templates开始/结束标签包装整个,但这显然不合法.有线索吗?
我正在编写一个函数,该函数将列出传递给 CGI 脚本的所有参数,无论是通过 POST 发送的表单、URL 字符串,还是两者。
为此有两个功能:
param():尽管文档,我发现这个阅读无论是POST方法的参数从一种形式或网址参数仅如果没有post数据。
另一方面,url_param()将永远只读取通过 URL 字符串传入的参数,而不管 POST。
我的功能
sub post_and_url_param_keys{
if(url_param){
return [url_param, param];
}else{
return [param];
}
Run Code Online (Sandbox Code Playgroud)
如果传入,它可以列出所有参数:
? POST 和 URL 参数
? 仅 POST 参数
仅X URL 参数(每个键列出两次)
有没有办法巧妙地解决这个问题,而不必检查每个参数对的名称和值是否有重复?
在 Magento 中,我们通常用来获取参数
http://magento.com/customer/account/view/id/122
Run Code Online (Sandbox Code Playgroud)
我们可以通过
$x = $this->getRequest()->getParam('id');
echo $x; // value is 122
Run Code Online (Sandbox Code Playgroud)
现在据我所知 $x 只是为了从参数中获取一个字符串。
有没有办法将 $x 作为数组获取?
例如:
Array
(
[0] => 122
[1] => 233
)
Run Code Online (Sandbox Code Playgroud) 我想在表中显示对象列表,表格没问题.我想将链接放在模板中一列显示的数据中.问题是,如何将该链接中的数据传递给视图?例如在struts2和JSP中,我曾经这样做过(使用param):
<td class="nowrap">
<s:url id="unitList" action="doSubject!ShowSubjectUnits">
<s:param name="subjectID" value="%{id}" />
</s:url>
<s:a href="%{unitList}"><s:text name="%{unidades.size()}"/></s:a>
</td>
Run Code Online (Sandbox Code Playgroud) 我想创建一个具有强大参数的对象,可以接受动态哈希键。
这是我的代码
Quiz.create(quiz_params)
def quiz_params
params.require(:quiz).permit(:user_id, :percent, :grade, questions: {})
end
Run Code Online (Sandbox Code Playgroud)
传入的数据看起来像这样。
// the keys that get passed into question is always different
quiz: {
user_id: 1,
percent: 80,
grade: "B",
questions: {
"12": "24",
"1": "12",
"4": "3",
"5": "22"
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当前,当我尝试创建测验时,问题哈希结果为空。
我想将一个数组作为参数传递给该方法尽可能多的值.例如,如果我进入[1,2,3]到add([1,2,3],我应该接收阵列的总和值.
def add(a, b)
a + b
end
def subtract(a, b)
a - b
end
Run Code Online (Sandbox Code Playgroud)
由于我是Ruby新手,我不知道如何解决这个问题.有人可以解释一下.