<data
<data
<set
<set
<set
<set
</data
</data
配置了數據源後
代碼如下所示
//獲取Servlet上下文對象
ServletContext ctx = servlet
//獲得數據源
DataSource ds = (DataSource) ctx
//獲取數據庫的連接
Connection conn = ds
B
Action將取得數據源
具體實現代碼如下所示
public class LoginAction extends Action {
public ActionForward execute(ActionMapping actionMapping
ActionForm actionForm
HttpServletResponse response) {
LoginActionForm loginform = (LoginActionForm) actionForm;
String username = loginform
String userpass = loginform
ServletContext ctx = servlet
DataSource ds = (DataSource) ctx
boolean flag = false;
[
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29130.html