我们可以在AbstractAnnotationConfigDispatcherServletInitializer的实现类中重写onStartup(ServletContext servletContext)方法添加其他的Servlet.Filter以及Listener public class SpringWebAppInit extends AbstractAnnotationConfigDispatcherServletInitializer { //Spring容器 @Override…
先来看一段常见的数据库操作代码: ``` protected User getDataFromDatabase(long id){ String sql = "select firstname from user where id=?";//1 Connection conn = DBConnectionFactory.getConnection(); PreparedStatement stat; User user;//2 try { stat = conn.prepareStat…