我正在使用 Java 7。是否可以根据特定属性值获取 ArrayList 中对象的索引。例如:
class Abc{
String first_name;
String last_name;
// getter and setters...
}
Run Code Online (Sandbox Code Playgroud)
现在
List<Abc> abcList = new ArrayList();
Abc abcObj = new Abc();
abcObj.setFirst_name("Jeet");
abcObj.setLast_name("Adhikari");
abcList.add(abcObj);
Abc abcObj2 = new Abc();
abcObj2.setFirst_name("John");
abcObj2.setLast_name("Something");
abcList.add(abcObj2);
Run Code Online (Sandbox Code Playgroud)
现在有没有更好的方法,无需迭代即可获取abcList中name = "John"的对象的索引。
我一直在阅读有关 Spring boot 的教程,在那里我学会了如何阻止 jackson 将日期转换为时间戳。例如:
{"birthDate":1505736233603} //before
{"birthDate":"2017-09-18T12:04:27.345+0000"}//after
Run Code Online (Sandbox Code Playgroud)
通过写作
spring.jackson.serialization.write-dates-as-timestamps=false
Run Code Online (Sandbox Code Playgroud)
在application.properties 中。
我该怎么做用SpringMVC为同一着,当然也没有application.properties在用SpringMVC
我正在尝试在使用 Resolve 加载组件之前调用 3 个不同的 API。
下面的这段代码写在解析函数中,并返回一个包含所有响应打包的对象。
现在当组件加载时,在我收到来自服务器的响应之前......它为返回的对象中的每个键返回 null。
请帮助我如何解决这个问题。在未从 API 收到响应之前,如何阻止它返回。
resolve() {
this._apiFactory.getA().subscribe(response => {
responseA = response;
});
this._apiFactory.getB().subscribe( response => {
responseB = response;
});
this._apiFactory.getC().subscribe( response => {
responseC = response;
});
return {
'A': responseA ,
'B': responseb ,
'C': responseC
};
}
Run Code Online (Sandbox Code Playgroud)