简单地说,我不能:
HTTPS推送
SSH推送
我是Java Threads和同步的新手.
让我们说:
public class MyClass(){
public synchronized void method1(){
//call method2();
}
public synchronized void method2(){};
}
Run Code Online (Sandbox Code Playgroud)
当我同步一个method1()实例对象时它意味着什么?因此,当一个线程在尝试访问时获取锁定时synchronized method1(),是否会阻止其他线程synchronized method2()从同一个对象访问另一个线程?
让我们说一个线程在访问method1()时获取一个锁,但是让我们说这也是method1()一个调用.这有可能吗?我的意思是有任何规则可以阻止呼叫吗?method2()synchronizedmethod1()method2()
提前致谢.
显然在实体bean中使用无状态EJB bean会有异味,但请考虑如下方案并告诉我您是否知道更好的解决方案:
InvoiceTemplate带有字段的实体BeanNextInvoiceDateNextInvoiceDate是一个复杂的过程,应该在InvoiceTemplate课外进行NextInvoiceDate应该每次都更新InvoiceTemplate存储到db现在我有关于实体bean NextInvoiceDate中的@PrePersist @PreUpdatemethon 生成的逻辑InvoiceTemplate.逻辑变得越来越复杂,我想将它移到InvoiceTemplate实体bean之外.它在我看来应该有一个服务来计算NextInvoiceDate.但那么从内部调用这项服务是否正确InvoiceTemplate?
我正在使用multipart将文件上传到服务器URLLoader.我可以上传文件.我试图在URLLoader上侦听progress事件,但它只在上传的最后触发.如何通过上传更加一致地获得进度事件?
从Spring API,我明白@InitBinder用于初始化一些绑定规则..
在petclinic的例子中为什么我们有setdisallowed("id")?当id没有显示在表单上时?
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
Run Code Online (Sandbox Code Playgroud)
id字段没有显示在网页上,那么为什么我们使用上面的代码呢?
我们可以有这样的事情:
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("FirstName");
}
Run Code Online (Sandbox Code Playgroud)
根据上面的代码,虽然用户在表单上输入,但不会设置所有者对象的名字字段?那是对的吗?
An Id作为Url参数传入.我试着确保它id是一个数字.如果没有重定向到主页面
if(facilityId != null){
try{
Long.parseLong(facilityId);
}catch(NumberFormatException e){
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("DisplayList.jsf");
} catch (IOException ex) {}
}
facility = documentSBean.findFacilityById(Long.parseLong(facilityId));
...
}
Run Code Online (Sandbox Code Playgroud)
所以,如果我传入这样的id
www....?facilityId=3?sdfasfda
Run Code Online (Sandbox Code Playgroud)
我发现这3?sdfasfda不是一个数字,并且转到redirect语句,但它没有正确地重定向,它执行下一对试图转换3?sdfasfda为Long的行,因此产生NumberFormatException.那么有没有办法立即强制重定向,或者是否有其他方法来解决这个问题.希望有一个else后catch:D:D.上面的代码在我的@PostConstruct init()方法中
我一般在Spring 3(和J2EE)中开始构建Web应用程序.看看petclinic的例子,我看到程序员创建了很多JSP片段,比如header,includes,footer,然后使用静态包含将它们拼接在一起.无论如何我想要的是我可能有一个基页,喜欢Base.jsp并且能够包含这样的东西:
<body>
<jsp:include page="${subpage}"></jsp:include>
</body>
Run Code Online (Sandbox Code Playgroud)
原因是我想要一个主页面,然后能够输入ModelAndView由控制器返回的页面部分在每种情况下显示(附有数据).这样可行,但如果${subpage}找不到,jsp名称错误或丢失,则不会出现错误.我想要更多的错误检查......
这是最好的和推荐的方法吗?如果这对我的想法似乎是一个好主意,那么正确的做法是什么?
<beans default-autowire="byType />
Run Code Online (Sandbox Code Playgroud)
表示如果不超过1个具有所需类型的bean,则bean的所有字段将自动注入依赖项.
问题是当使用注释时这是如何工作的,它是否有效.
我的测试显示,即使我使用
@Resource(name="someConcreteFoo")
private Foo foo;
Run Code Online (Sandbox Code Playgroud)
上下文尝试按类型自动装配字段,如果有多个实现,则失败Foo.因此,对于我所看到的,default-autowire不会与注释混在一起.我在文档中找不到任何具体内容.
扩展问题 - 当使用xml-only时,spring如何使用default-autowiring进行操作.即如果你有的话<property>.属性注入是否覆盖默认值(应该是).
我可以做更多的测试,但我更喜欢某些引用确认的行为.任何见解?
GenericServlet实现ServletConfig接口,这意味着可以从init()函数中调用所有接口函数GenericServlet.鉴于此上下文,为什么Servlet容器将ServletConfig对象发送给init()方法?我还想知道ServletConfig传递给GenericServlet.init(ServletConfig)GenericServlet对象的对象是否不同.
此致,拉维
注意到如果我想读取一些数据,如果我没有事务上下文,我将无法这样做,因为
org.hibernate.HibernateException:找不到当前线程的Session
对于读取数据,通常不需要事务.
因此,为了让Spring管理会话,即使对于只读操作,它也需要进行交易...?
这不是开销吗?
PS.I不想手动打开和关闭会话...
非常感谢.
java ×6
spring ×4
spring-mvc ×2
apache-flex ×1
ejb-3.0 ×1
file-upload ×1
git ×1
github ×1
hibernate ×1
java-ee ×1
jpa ×1
jsf ×1
jsp ×1
redirect ×1
servlets ×1
transactions ×1
urlloader ×1