servlet中注入service ,先声明service ,后再方法中new;与不声明,直接实例化有区别吗?
1、先声明,再在方法中new
private MessageService msgService;
public 。。。{
msgService=new MessageService ();
}
2、不声明,直接在方法中new
MessageService msgService=new MessageService ();
1、先声明,再在方法中new
private MessageService msgService;
public 。。。{
msgService=new MessageService ();
}
2、不声明,直接在方法中new
MessageService msgService=new MessageService ();
2015-12-09
举报