请慎用spring-ClassPathXmlApplicationContext手动加载spring配置文件(二)

2014-11-24 11:01:17 · 作者: · 浏览: 1
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]
springInitServlet
com.panda.util.springDB.SpringInitServlet
1