如何在AWS上配置ElasticBeanstalk以在URL中允许编码斜杠?(使用-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH = true)
我已经在源包的顶级目录(http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html)中创建了一个名为.ebextensions的目录,其中包含文件tomcat.config 内容:
commands:
allow-encoded-slash:
command: export CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
cwd: /home/ec2-user
Run Code Online (Sandbox Code Playgroud)
但是它似乎没有作用,也没有出现在这些目录中:
ls -la /tmp/deployment/application/ROOT/
ls -la /var/lib/tomcat7/webapps/ROOT/
Run Code Online (Sandbox Code Playgroud) 当 RxAlamofire 调用发生错误时,我需要响应正文。我见过这个黑客,但我想知道是否有更清洁的方法。
受它的启发,我使用类似的 hack创建了这个RxAlamofire fork。有了它,错误通常是一个实例,DataResponseError所以你可以这样做:
RxAlamofire.data(method, url).subscribe(
onError: { error in
if let error = error as? DataResponseError<Data> {
// Get response body (in this case, convert it to a String)
if let data = error.response.data {
let message = String(data: data, encoding: String.Encoding.utf8)
print("Message: \(message)")
}
// Get status code
if let statusCode = error.response.response?.statusCode {
print("Status code: \(statusCode)")
}
}
}
)
Run Code Online (Sandbox Code Playgroud) 如果我有 2 个视图,我想要一个占用必要的空间,另一个占用剩余的空间,我应该怎么做?
假设我想垂直放置视图。下面的视图应该占用必要的空间(wrap_content),上面的视图应该占用容器布局的剩余空间。
我使用了这两个解决方案(简化代码):
1)LinearLayout与weight
<LinearLayout ...>
<View height="0dp" weight="1" .../>
<View height="wrap_content" .../>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
2)RelativeLayout对齐
<RelativeLayout ...>
<View height="wrap_content" id="@+id/big" alignParentTop .../>
<View height="wrap_content" below="@+id/big" alignParentBottom .../>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
该LinearLayout方法始终有效,并且RelativeLayout通常按预期工作,但这显然是模棱两可的,因为没有什么说@+id/big视图应该大于下面的视图。
我认为第一种方法更好,因为它没有歧义。但是,我已经看到了第二种方法的许多示例和答案。
对于这些情况,您使用什么解决方案。有最佳实践吗?
谢谢!
编辑
以Touf的回答,现在我会这样做(注意match_parent):
<RelativeLayout ...>
<View height="match_parent" id="@+id/big" alignParentTop .../>
<View height="wrap_content" below="@+id/big" alignParentBottom .../>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我试着爱可信图书馆angularjs,当我看到改变我很惊讶$scope被角检测到爱可信回调。我以为我必须打个电话$apply,例如在使用时setTimeout。
// axios example
axios.get(url).then((response) => {
// Here I don't need $apply, why??
$scope.axiosResult = response.data;
});
// setTimeout example
setTimeout(() => {
// Here I need $apply for the timeoutResult to appear on the HTML
$scope.$apply(() => $scope.timeoutResult = {message: "timeout!"});
}, 2000)
Run Code Online (Sandbox Code Playgroud)
您知道为什么$apply在axios中不需要吗?
编辑:
georgeawg的评论帮助我看到了我$http在其他地方使用的信息,因此我猜测由触发的摘要循环$http也有助于axios回调被“消化”。