日期:2014-05-17 浏览次数:20662 次
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { dataSource.getConnection(); } catch (SQLException e) {} userManager.addUser(null); }
<!-- 配置连接池 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost/assignment</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>root</value> </property> </bean> <!-- Servlet中配置UserManager --> <bean id="userManager" class="com.dao.impl.UserManagerImpl" /> <bean name="/addUserServlet" class="com.servlet.addUserServlet"> <property name="dataSource" ref="dataSource"></property> <property name="userManager" ref="userManager"></property> </bean>
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>