所以我有一个如下所示的 JSON:
{
"name": "customer",
"properties": [
{
"name": "id",
"type": "int",
"value": 32
},
{
"name": "name",
"type": "string",
"value": "John"
}
]
}
Run Code Online (Sandbox Code Playgroud)
目前我正在反序列化到这组结构:
#[derive(Serialize, Deserialize, Debug)]
struct Customer {
name: String,
properties: Vec<Property>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "name", content = "value")]
enum Property {
#[serde(rename = "id")]
Id(i32),
#[serde(rename = "name")]
Name(String),
}
Run Code Online (Sandbox Code Playgroud)
但为了避免每次我想访问一个属性时都要处理枚举匹配,我想将其反序列化为如下所示的结构:
struct Customer {
name: String,
properties: Properties,
}
struct Properties {
id: i32, // will be 32 as in the object …Run Code Online (Sandbox Code Playgroud) 假设我有一个相对简单的对象,具有两个属性:
@Data
public class MyObject {
public Integer a;
public Integer b;
}
Run Code Online (Sandbox Code Playgroud)
我可以安全地在某个线程中改变 a 并在其他线程中安全地改变 b 吗?例如,这段代码不会受到竞争条件的影响吗?
public MyObject compute() {
MyObject newObj = new MyObject();
List<Runnable> tasks = new ArrayList<>();
Runnable computeATask = () -> {
Integer a = computeA();
newObj.setA(a);
};
Runnable computeBTask = () -> {
Integer b = computeB();
newObj.setB(b);
};
tasks.add(computeATask);
tasks.add(computeBTask);
tasks.stream().parallel().forEach(Runnable::run);
return newObj;
}
Run Code Online (Sandbox Code Playgroud) 我有一个简单的表单,只包含一个用于下载文件的按钮.这是代码:
<form method='post' action='download.php?file=file.txt' name='form1'>
<button type='submit'>Telecharger</button>
</form>
Run Code Online (Sandbox Code Playgroud)
Download.php是一个小的php文件,带有用于下载的标题,这里是:
<?php
$filename=$_GET['file'];
header('Content-Type: text/plain');
header("Content-disposition: attachment;filename=$filename");
readfile($filename);
?>
Run Code Online (Sandbox Code Playgroud)
我要做的是在用户点击它之后隐藏按钮或表单.到目前为止,我已尝试使用css和javascript监听器,但到目前为止没有任何工作.
当我点击按钮时,它会下载文件,但不会隐藏按钮.
提交表格后如何隐藏按钮?