有什么区别XPath,XQuery和XPointer?据我所知,XQuery是一个扩展版本XPath.我有一些基本的知识XPath.是否有任何功能提供XPath这不XQuery?昨天,我听到一个新词,XPointer.我很迷惑.哪种语言用于哪种目的?
我有类别列表.我需要排除2,3行的类别列表.我们可以通过使用Criteria和Restriction来实现休眠吗?
在我的应用程序中,我要求将12小时的时间格式化为24小时.我必须使用哪种方法?
例如,时间如上午10:30.我怎样才能在java中转换为24小时的时间?
在发现在Java 1.6上FutureTask运行Executors.newCachedThreadPool()(以及从Eclipse中)吞下Runnable.run()方法中的异常后,我试图找到一种方法来捕获这些,而不向我的所有Runnable实现添加throw/catch .
API建议覆盖FutureTask.setException()应该有助于此:
导致此未来报告ExecutionException,并将给定的throwable作为其原因,除非已设置或已取消此Future.在计算失败时,run方法在内部调用此方法.
但是,似乎没有调用此方法(使用调试器运行显示异常被捕获FutureTask但setException未被调用).我写了以下程序来重现我的问题:
public class RunTest {
public static void main(String[] args) {
MyFutureTask t = new MyFutureTask(new Runnable() {
@Override
public void run() {
throw new RuntimeException("Unchecked exception");
}
});
ExecutorService service = Executors.newCachedThreadPool();
service.submit(t);
}
}
public class MyFutureTask extends FutureTask<Object> {
public MyFutureTask(Runnable r) {
super(r, null);
}
@Override
protected void setException(Throwable t) {
super.setException(t);
System.out.println("Exception: " + t);
} …Run Code Online (Sandbox Code Playgroud) 所有模板都存储在数据库中.我必须从数据库中获取模板的内容并用freemarker标记.结束输出将在文本框中呈现.
但是,我没有找到任何方法可以发送字符串而不是文件名.
请建议.
我参加过面试.面试官问我为什么需要私人变量.如果通过定义变量private来实现某些功能,那么通过定义java中定义的任何其他访问修饰符,您是否能够实现相同的目标?
According to Java Specification Languages, A private class member or constructor is accessible only within the body of the top level class (7.6) that encloses the declaration of the member or constructor. It is not inherited by subclasses.
但是,如果我正在设计一个类,我如何决定定义变量"私有"?
我正在使用bootstrap 2.3.2并希望实现元素看起来像下拉菜单.github中有一个解决方案:https://github.com/silviomoreto/bootstrap-select
我的代码:
<select class="selectpicker">
<option>1</option>
<option>2</option>
</select>
<script type="text/javascript">
$( function() {
$('.selectpicker').selectpicker();
})
</script>
Run Code Online (Sandbox Code Playgroud)
它不起作用.但是当我打字的时候
$('.selectpicker').selectpicker();
Run Code Online (Sandbox Code Playgroud)
在Chrome DevTools的控制台中 - 选择更改为下拉列表并且它可以正常工作.
我有一个非常基本的问题,java.util.Set何时检查添加的对象是否重复?
因为我有一个如下所示的模型类,它会覆盖equals和hashcode方法
public class SampleModel implements Comparable {
private String name;
public SampleModel(String name) {
this.name = name;
}
// Setter and Getter omitted
@Override
public boolean equals(Object arg0) {
boolean eq = false;
if (arg0 instanceof SampleModel
&& this.name.equalsIgnoreCase(((SampleModel) arg0).name)) {
eq = true;
}
return eq;
}
@Override
public int compareTo(Object arg0) {
return this.name.compareTo(((SampleModel) arg0).name);
}
@Override
public int hashCode() {
return this.name.length();
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我在HashSet中使用模型对象的方法.
SampleModel s1 = new SampleModel("Satya");
SampleModel s2 = new SampleModel("Katti");
Set<SampleModel> …Run Code Online (Sandbox Code Playgroud) 我对Spring的生命周期感到困惑.
XmlBeanFactory beanFactory
= new XmlBeanFactory(new ClassPathResource("SpringHelloWorld.xml"));
Run Code Online (Sandbox Code Playgroud)
上面的代码片段是否创建了对象?
如果上述答案是真的.
a)然后,对于范围为"singleton"的bean,获取在上面的代码片段中创建的对象.我是对还是错?
b)对于范围是"原型"的情况,创建的对象是否未使用.因为,容器总是返回新对象.
XmlBeanFactory beanFactory
= new XmlBeanFactory(new ClassPathResource("SpringHelloWorld.xml"));
Run Code Online (Sandbox Code Playgroud)
上面的代码片段是否创建了对象?
如果答案是假的,
spring框架如何验证bean定义是否正确.
From the answer of Henry
Usually, singleton beans are created when the context starts. This can be changed with the lazy-init or default-lazy-init attributes.
Prototype beans are only created when needed.
Only syntactically, there might still be errors when the bean is instantiated, for example if a required property is not provided.
java ×7
concurrency ×1
criteria ×1
equals ×1
freemarker ×1
futuretask ×1
hashcode ×1
hashset ×1
hibernate ×1
lifecycle ×1
restriction ×1
set ×1
spring ×1
time ×1
xml ×1
xpath ×1
xquery ×1