请慎用spring-ClassPathXmlApplicationContext手动加载spring配置文件(二)
private SpringDBInit sdbinit = SpringDBInit.getInstance();
/**
* servlet初始化
*/
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
Properties props = new Properties();
props.put("APP_CONTEXT", config.getServletContext());
// 文件路径
String prefix = getServletContext().getRealPath("/");
// web应用路径
props.put("APP_PATH", prefix);
try
{
sdbinit.init(props);
}
catch (Exception e)
{
}
}
}
web.xml配置:
[
html]