我无法理解@ValidateOnExecution批注的本质。有人可以解释一下用例吗?
根据jersey的文档,对资源方法的约束将自动进行验证。此代码段来自jersey的示例。
@GET
@NotNull
@HasId
public List<ContactCard> getContacts() {
return StorageService.findByName("");
}
@GET
@Path("{id}")
@NotNull(message = "{contact.does.not.exist}")
@HasId
public ContactCard getContact(
@DecimalMin(value = "0", message = "{contact.wrong.id}")
@PathParam("id") final Long id) {
return StorageService.get(id);
}
Run Code Online (Sandbox Code Playgroud)
如果约束在pojo中,则可以使用@Valid触发验证(请参见参考资料)。
@Path("/")
class MyResourceClass {
@POST
@Consumes("application/xml")
public void registerUser(@Valid User user) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
那么@ValidateOnExecution除了明确关闭了验证功能外,还有什么用?
我有一些关于 CSS 网格元素的问题<input>。
block在 CSS 网格中显示,但在简单的 div 中显示为内联元素?inline浏览器忽略?最后,这里有一个隐含的“我该如何解决这个问题”的问题。
这是一个例子:
.wrapper {
background-color: purple;
display: grid;
grid-template-columns: 1fr 4rem 4rem 1fr;
}
.wrapper > label {
display: inline;
grid-column: 2;
background-color:green;
}
.wrapper > input[type=checkbox] {
grid-column: 3;
border: 1px solid red;
background-color: gray;
}
.wrapper > input[type=text] {
grid-column: 4;
outline: 2px solid yellow;
}
.simple {
width: 50px;
height: 100px;
background-color: blue;
}
.simple > label {
height: 50px;
} …Run Code Online (Sandbox Code Playgroud)我想使用 jdbc 数据存储立即使用石英调度程序执行作业。但是,即使我使用 now() 或调用 triggerJob 进行调度,我在调度和触发触发之间也有 20-30 秒的延迟。
我试图用一个简单的触发器来执行这项工作:
JobKey key = //...
JobDetail jobDetail = newJob(jobBean.getClass())
.withIdentity(key)
.usingJobData(new JobDataMap(jobParams))
.storeDurably()
.build();
Trigger trigger = newTrigger()
.withIdentity(key.getName(), key.getGroup())
.startNow()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withMisfireHandlingInstructionFireNow()
.withRepeatCount(0))
.build();
scheduler.scheduleJob(jobDetail, trigger);
Run Code Online (Sandbox Code Playgroud)
而且我还尝试使用调度程序触发:
JobKey key = // ...
JobDetail jobDetail = newJob(jobBean.getClass())
.withIdentity(key)
.storeDurably()
.build();
scheduler.addJob(jobDetail, true);
scheduler.triggerJob(key, new JobDataMap(jobParams));
Run Code Online (Sandbox Code Playgroud)
以下是显示延迟的侦听器日志。
2019-05-15 13:59:52,066Z INFO [nio-8081-exec-2] c.m.f.s.logger.SchedulingListener : Job added: newsJobTemplate:1557928791965
2019-05-15 13:59:52,066Z INFO [nio-8081-exec-2] c.m.f.s.logger.SchedulingListener : Job scheduled: newsJobTemplate:1557928791965
2019-05-15 14:00:18,660Z INFO [eduler_Worker-1] c.m.f.s.logger.TriggerStateListener : Trigger …Run Code Online (Sandbox Code Playgroud)