从nginx docker 页面,要运行 nginx 映像,我们需要:
docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
我了解该选项将主机上的-v /some/content:/usr/share/nginx/html:ro目录安装/some/content到容器的/usr/share/nginx/html目录。
但:ro最后做什么呢?
我必须实现状态转换验证,例如:
'P' -> 'W' -> 'M' -> 'F' -> 'G'
'P' -> 'I' -> 'B' -> 'M' -> 'F' -> 'G'
Run Code Online (Sandbox Code Playgroud)
其中"->"表示"可以移动到"
简而言之,特定状态只能转移到某种状态,而不能转移到其他状态.如上例所示,P可以移动到W或I,但不能移动到任何其他状态.
注意:系统中的状态数量有限.
我读过有关策略模式的内容,但我并不认为这个特殊问题适合它.在Java 8中实现这一点的最佳方法是什么?
我的html如下所示:
<div class="list-item">
<div class="details">
<a href="https://link_to_Item_1" />
</div>
</div>
<div class="list-item">
<div class="details">
<a href="https://link_to_Item_2" />
</div>
</div>
<div class="list-item">
<div class="details">
<a href="https://link_to_Item_3" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用jQuery,我想从上面的HTML创建一个如下对象:
[
{
position :1,
url: "https://link_to_Item_1"
},
{
position :"2",
url: "https://link_to_Item_1"
},
{
position :"3",
url: "https://link_to_Item_2"
}
]
Run Code Online (Sandbox Code Playgroud)
我尝试了以下内容:
var myData = [];
var myDataElements = {};
$('.list-item').find('a').each(function(index, ele){
myDataElements.position = index;
myDataElements.url = $(this).attr('href');
myData.push(myDataElements);
});
Run Code Online (Sandbox Code Playgroud)
但是结果是myData中所有元素的位置和URL都相同。
我有一个包含如下值的字符串列表:
String [] arr = {"${US.IDX_CA}", "${UK.IDX_IO}", "${NZ.IDX_BO}", "${JP.IDX_TK}", "${US.IDX_MT}", "more-elements-with-completely-different-patterns-which-is-irrelevant"};
Run Code Online (Sandbox Code Playgroud)
我正在尝试从此列表中提取所有 IDX_XX。所以从上面的列表中,我应该在 Java 中使用正则表达式 IDX_CA、IDX_IO、IDX_BO 等
我写了以下代码:
Pattern pattern = Pattern.compile("(.*)IDX_(\\w{2})");
for (String s : arr){
Matcher m = pattern.matcher(s);
if (m.matches()){
String extract = m.group(1);
System.out.println(extract);
}
}
Run Code Online (Sandbox Code Playgroud)
但这不会打印任何内容。有人可以告诉我我犯了什么错误。谢谢。
我有一个如下所示的对象:
public class Resource {
int level;
String identifier;
boolean isEducational;
public Resource(String level, String identifier, boolean isEducational) {
this.level = level;
this.identifier = identifier;
this.isEducational = isEducational;
}
// getter and setters
}
Run Code Online (Sandbox Code Playgroud)
这些资源的列表如下:
List<Resource> resources = Arrays.asList(new Resource(4, "a", true ),
new Resource(4, "b", false),
new Resource(3, "c", true ),
new Resource(3, "d", false ),
new Resource(2, "e", true ),
new Resource(2, "f" , false));
Run Code Online (Sandbox Code Playgroud)
我想按其属性对这个列表进行排序,但是这种排序应该针对资源和非资源level分别进行。isEducationalisEducational
因此,排序后,结果列表应按以下顺序排列:
[Resource e, Resource c, Resource …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MERGEOracle 12 DB 表上的语句执行 upsert 操作CONFIG,该表的架构如下所示:
id | name | value
Run Code Online (Sandbox Code Playgroud)
如果存在带有“NON_TAXABLE_CODE”的行name,请将其更新value为“400”,否则在其中插入新行。
第一次尝试
MERGE into CONFIG dest USING (SELECT id, name, value from CONFIG where name = 'NON_TAXABLE_CODE') src
ON (dest.name = src.name)
WHEN MATCHED THEN
UPDATE SET dest.value = src.value
WHEN NOT MATCHED THEN
INSERT (id, name, value) VALUES (src.id, src.name, src.value )
Run Code Online (Sandbox Code Playgroud)
如果该行存在,这将更新该值,但不会插入新行(如果不存在行)
第二次尝试:
MERGE into CONFIG as dest USING VALUES (0, 'NON_TAXABLE_CODE', '400') as src (id, name, value)
ON …Run Code Online (Sandbox Code Playgroud)