我正在尝试学习线程,我不明白这个join()方法.
我有一个Thread(ThreadAdd.java),它将1添加到静态int.
public class ThreadAdd extends Thread{
public static int count;
@Override
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(ThreadAdd.class.getName()).log(Level.SEVERE, null, ex);
}
ThreadAdd.count++;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的main方法中,我启动2个线程:
public static void main(String[] args) throws InterruptedException {
ThreadAdd s1 = new ThreadAdd();
ThreadAdd s2 = new ThreadAdd();
s1.start();s2.start();
s1.join();
s2.join();
System.out.println(ThreadAdd.count);
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么大多数时候结果是2但有时它返回1.
我有一个这样的班点:
class Point {
@test('admin') x: number = 6
y: number = 5
}
Run Code Online (Sandbox Code Playgroud)
使用测试装饰器:
function test(myValue: string) {
function t(target: Object, propertyKey: string, descriptor:
TypedPropertyDescriptor<any>) {
//want to test y value > x value
}
return <any>t
}
Run Code Online (Sandbox Code Playgroud)
在我的测试中,我想检查 y 值,例如如果 x < y 抛出错误
是否可以 ?
我想使用Guzzle和Silex向https页面发送请求.
使用http url我有一个回复:
app->get('/',function() use ($app, $client){
$response = $client->get("http://www.google.fr");
var_dump($response);
});
Run Code Online (Sandbox Code Playgroud)
我的回复:
object(GuzzleHttp\Message\Response)[102]
private 'reasonPhrase' => string 'OK' (length=2)
private 'statusCode' => int 200
private 'effectiveUrl' => string 'http://www.google.fr' (length=20)
private 'headers' (GuzzleHttp\Message\AbstractMessage) =>
array (size=13)
'date' =>
array (size=1)
0 => string 'Wed, 18 Feb 2015 10:57:37 GMT' (length=29)
'expires' =>
Run Code Online (Sandbox Code Playgroud)
但是使用https:
$app->get('/',function() use ($app, $client){
$url = "https://api.zoapp.com/v1/stc/cans/directory/pub/Employees";
$response = $client->get("https://www.facebook.com/");
var_dump($response);
});
Run Code Online (Sandbox Code Playgroud)
我有错误:
RequestException in RequestException.php line 51:
Run Code Online (Sandbox Code Playgroud)
和
RingException in CurlFactory.php line 126:
Run Code Online (Sandbox Code Playgroud)
细节:pastbin链接
我想在表单中发送文件和隐藏的输入文本.
<form method="POST" action="/api/import_xlsx_data" enctype="multipart/form-data">
<input type="file" name="xlsx_file_to_import" accept=".xlsx" required>
<input id="url" type="HIDDEN" name="url" value="url-value">
<input type="submit" value="Envoyer">
Run Code Online (Sandbox Code Playgroud)
在我的控制器request.body等于{}.
当我删除enctype ="multipart/form-data"时,它适用于我的文本,但不适用于我的文件.
要上传我的文件:
uploadFile.upload({saveAs : fileName, dirname : directoryName},function onUploadComplete(err, files) { ...............});
Run Code Online (Sandbox Code Playgroud)
我的控制器:
importXLS: function (req, res) {
var uploadFile = req.file('xlsx_file_to_import');
//console.log(req.params()); -> send error params is not a function
console.log(req.body); // send me {}
console.log(req.param('url')); //send me undefined
...... }
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我想在我的视图中发送一条消息:
res.status(400).view('memberRegisterView',{error : "error"});
Run Code Online (Sandbox Code Playgroud)
我想用法语翻译这个错误并且有"错误".
我编辑了i18n.js:
locales: ['en', 'fr'],
defaultLocale: 'fr'
Run Code Online (Sandbox Code Playgroud)
在我的en.json中:
"error":"error"
Run Code Online (Sandbox Code Playgroud)
在我的fr.json中:
"error":"erreur"
Run Code Online (Sandbox Code Playgroud)
如何在我的控制器中使用翻译?
sails.js ×2
controller ×1
decorator ×1
enctype ×1
guzzle ×1
https ×1
java ×1
javascript ×1
node.js ×1
object ×1
post ×1
properties ×1
silex ×1
translation ×1
typescript ×1
view ×1