﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-java客栈-文章分类-Struts初涉</title><link>http://www.blogjava.net/Areschina/category/4883.html</link><description>小鸟也疯狂^_^</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 18:03:06 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 18:03:06 GMT</pubDate><ttl>60</ttl><item><title>简单的struts应用开发（5）</title><link>http://www.blogjava.net/Areschina/articles/19953.html</link><dc:creator>Areschina</dc:creator><author>Areschina</author><pubDate>Tue, 15 Nov 2005 12:34:00 GMT</pubDate><guid>http://www.blogjava.net/Areschina/articles/19953.html</guid><wfw:comment>http://www.blogjava.net/Areschina/comments/19953.html</wfw:comment><comments>http://www.blogjava.net/Areschina/articles/19953.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Areschina/comments/commentRss/19953.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Areschina/services/trackbacks/19953.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">简单的</SPAN><SPAN lang=EN-US>struts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用开发（</SPAN><SPAN lang=EN-US>5</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US><BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第六步</SPAN><SPAN lang=EN-US>:</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立</SPAN><SPAN lang=EN-US>JSP</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">视图页面</SPAN><SPAN lang=EN-US> (</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">主要有两个</SPAN><SPAN lang=EN-US>jsp</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件</SPAN><SPAN lang=EN-US>. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">添加页面</SPAN><SPAN lang=EN-US>. adduser.jsp </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">查看页面</SPAN><SPAN lang=EN-US> viewuser.jsp) <BR><BR>adduser.jsp <BR><BR>&lt;%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %&gt; <BR>&lt;%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %&gt; <BR>&lt;%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %&gt; <BR>&lt;%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %&gt; <BR>&lt;%@ page contentType="text/html; charset=gb2312" %&gt; <BR>&lt;html:html&gt; <BR>&lt;head&gt; <BR>&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt; <BR>&lt;title&gt; <BR>adduser <BR>&lt;/title&gt; <BR>&lt;/head&gt; <BR>&lt;body&gt; <BR>&lt;h1&gt; &lt;/h1&gt; <BR>&lt;p&gt; <BR>&lt;html:form action="/user1Action.do" method="POST"&gt; <BR>&lt;html:hidden property="action"/&gt; <BR>&lt;br&gt; <BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">部门</SPAN><SPAN lang=EN-US>: <BR>&lt;html:select property="dep"&gt; <BR>&lt;html:options collection="dep" property="id" labelProperty="name1"/&gt; <BR>&lt;/html:select&gt; <BR>&lt;br&gt; <BR>ID: <BR>&lt;logic:equal name="userActionForm" property="action" scope="request" value="add"&gt; <BR>&lt;html:text property="user_id"/&gt; <BR>&lt;/logic:equal&gt; <BR>&lt;logic:equal name="userActionForm" property="action" scope="request" value="edit"&gt; <BR>&lt;html:text property="user_id" readonly="true"/&gt; <BR>&lt;/logic:equal&gt; <BR>&lt;br&gt; <BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">名字</SPAN><SPAN lang=EN-US>:&lt;html:text property="user_name"/&gt; <BR>&lt;br&gt; <BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">电话</SPAN><SPAN lang=EN-US>:&lt;html:text property="tel"/&gt; <BR>&lt;br&gt; <BR>&lt;html:submit property="submit" value="Submit"/&gt;&lt;br&gt; <BR>&lt;html:reset value ="Reset"/&gt; <BR>&lt;/html:form&gt; <BR>&lt;/body&gt; <BR>&lt;/html:html&gt; <BR><BR>viewuser.jsp <BR><BR>&lt;%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %&gt; <BR>&lt;%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %&gt; <BR>&lt;%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %&gt; <BR>&lt;%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %&gt; <BR>&lt;%@ page contentType="text/html; charset=GBK" %&gt; <BR>&lt;html:html&gt; <BR>&lt;head&gt; <BR>&lt;title&gt; <BR>viewuser <BR>&lt;/title&gt; <BR>&lt;/head&gt; <BR>&lt;body&gt; <BR>&lt;div align="center"&gt;&lt;a href="userAction.do?action=add"&gt;add &lt;/a&gt;&lt;/div&gt; <BR>&lt;table width="60%" border="1" align="center"&gt; <BR>&lt;tr bgcolor="#CCCCCC"&gt; <BR>&lt;td&gt;ID&lt;/td&gt; <BR>&lt;td&gt;user_name&lt;/td&gt; <BR>&lt;td&gt;dep&lt;/td&gt; <BR>&lt;td&gt;tel&lt;/td&gt; <BR>&lt;td&gt;modify&lt;/td&gt; <BR>&lt;td&gt;del&lt;/td&gt; <BR>&lt;/tr&gt; <BR>&lt;logic:iterate name="rs" id="user" scope="request" type="java.util.HashMap"&gt; <BR>&lt;tr&gt; <BR>&lt;td&gt;&lt;bean:write name="user" property="user_id"/&gt; &lt;/td&gt; <BR>&lt;td&gt;&lt;bean:write name="user" property="user_name"/&gt; &lt;/td&gt; <BR>&lt;td&gt;&lt;bean:write name="user" property="dep_name"/&gt; &lt;/td&gt; <BR>&lt;td&gt;&lt;bean:write name="user" property="tel"/&gt; &lt;/td&gt; <BR>&lt;td&gt;&lt;a href="userAction.do?action=edit&amp;key=&lt;bean:write name="user" property="user_id"/&gt;"&gt;modify&lt;/a&gt;&lt;/td&gt; <BR>&lt;td&gt;&lt;a href="userAction.do?action=del&amp;key=&lt;bean:write name="user" property="user_id"/&gt;"&gt;del&lt;/a&gt;&lt;/td&gt; <BR>&lt;/tr&gt; <BR>&lt;/logic:iterate&gt; <BR>&lt;/table&gt; <BR>&lt;/body&gt; <BR>&lt;/html:html&gt; <BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建产一个转向页面</SPAN><SPAN lang=EN-US> (index.jsp) <BR>&lt;%@ page contentType="text/html; charset=gb2312" %&gt; <BR>&lt;html&gt; <BR>&lt;head&gt; <BR>&lt;title&gt;Untitled Document&lt;/title&gt; <BR>&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt; <BR>&lt;/head&gt; <BR><BR>&lt;body&gt; <BR>&lt;% response.sendRedirect("userAction.do?action=view"); %&gt; <BR>&lt;/body&gt; <BR>&lt;/html&gt; <BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">递七步</SPAN><SPAN lang=EN-US>:</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立</SPAN><SPAN lang=EN-US>struts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置文件</SPAN><SPAN lang=EN-US> (WEB-INF/config-struts.xml) <BR><BR>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <BR>&lt;!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"&gt; <BR>&lt;struts-config&gt; <BR>&lt;form-beans&gt; <BR>&lt;form-bean name="userActionForm" type="mystruts.userActionForm" /&gt; <BR>&lt;/form-beans&gt; <BR>&lt;action-mappings&gt; <BR>&lt;action type="mystruts.userAction" scope="request" path="/userAction"&gt; <BR>&lt;forward name="view" path="/viewuser.jsp" /&gt; <BR>&lt;forward name="add" path="/adduser.jsp" /&gt; <BR>&lt;forward name="delview" path="/userAction.do?action=view" /&gt; <BR>&lt;/action&gt; <BR>&lt;action name="userActionForm" type="mystruts.user1Action" scope="request" path="/user1Action"&gt; <BR>&lt;forward name="view" path="/userAction.do?action=view" /&gt; <BR>&lt;/action&gt; <BR>&lt;/action-mappings&gt; <BR>&lt;/struts-config&gt; <BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行程序</SPAN><SPAN lang=EN-US>: <BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">启动</SPAN><SPAN lang=EN-US>tomcat <BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">启动</SPAN><SPAN lang=EN-US>IE </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在地址栏中输入</SPAN><SPAN lang=EN-US> http://localhost:8080/mystruts <BR><BR>OK..... </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（全文完）</SPAN></P><img src ="http://www.blogjava.net/Areschina/aggbug/19953.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Areschina/" target="_blank">Areschina</a> 2005-11-15 20:34 <a href="http://www.blogjava.net/Areschina/articles/19953.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的struts应用开发（1）</title><link>http://www.blogjava.net/Areschina/articles/19951.html</link><dc:creator>Areschina</dc:creator><author>Areschina</author><pubDate>Tue, 15 Nov 2005 12:33:00 GMT</pubDate><guid>http://www.blogjava.net/Areschina/articles/19951.html</guid><wfw:comment>http://www.blogjava.net/Areschina/comments/19951.html</wfw:comment><comments>http://www.blogjava.net/Areschina/articles/19951.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Areschina/comments/commentRss/19951.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Areschina/services/trackbacks/19951.html</trackback:ping><description><![CDATA[<SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">简单的<SPAN lang=EN-US>struts</SPAN>应用开发（<SPAN lang=EN-US>1</SPAN>）<SPAN lang=EN-US><BR><BR></SPAN>终于把自己的这个测试做完了<SPAN lang=EN-US>. </SPAN>希望对想学<SPAN lang=EN-US>struts</SPAN>的新手有所帮助<SPAN lang=EN-US>. <BR><BR>(mystruts</SPAN>应用<SPAN lang=EN-US>)</SPAN>目录结构<SPAN lang=EN-US> <BR>mystruts <BR>|-WEB-INF <BR>| |- lib <BR>| | |- struts.jar <BR>| |- classes <BR>| | |- ConnectionPool <BR>| | | |- getDbConnection.class <BR>| | |-mystruts <BR>| | |- user1Action.class <BR>| | |- userAction.class <BR>| | |- userActionForm.class <BR>| | |- userdao.class <BR>| |-struts-bean.tld <BR>| |-struts-config.xml <BR>| |-struts-html.tld <BR>| |-struts-logic.tld <BR>| |-struts-template.tld <BR>|-adduser.jsp <BR>|-index.jsp <BR>|-viewuser.jsp <BR><BR></SPAN>第一步<SPAN lang=EN-US>: </SPAN>开发环境配置<SPAN lang=EN-US> <BR><BR>(</SPAN>如果你还没有相关软件<SPAN lang=EN-US>. </SPAN>请到<SPAN lang=EN-US>http://www.apache.org </SPAN>下载<SPAN lang=EN-US>) <BR><BR>tomcat5.0 </SPAN>配置<SPAN lang=EN-US> (</SPAN>建立一个<SPAN lang=EN-US> mystruts </SPAN>应用<SPAN lang=EN-US>, </SPAN>并拷贝相关文件<SPAN lang=EN-US>) <BR><BR></SPAN>请在你的<SPAN lang=EN-US>tomcat</SPAN>安装目录中找到<SPAN lang=EN-US>\conf\Catalina\localhost </SPAN>子目录<SPAN lang=EN-US>. </SPAN>新建<SPAN lang=EN-US> mystruts.xml </SPAN>文件<SPAN lang=EN-US> <BR></SPAN>文件内容如下<SPAN lang=EN-US>. </SPAN>在这个文件中<SPAN lang=EN-US>. </SPAN>我们将配置一个联接池<SPAN lang=EN-US>.</SPAN>请把相关的驱动<SPAN lang=EN-US>.</SPAN>数据库用户<SPAN lang=EN-US>,</SPAN>密码改成你自己的本机配置<SPAN lang=EN-US>. <BR></SPAN>并把<SPAN lang=EN-US>JDBC</SPAN>驱动拷贝一份到<SPAN lang=EN-US> Tomcat 5.0\common\lib </SPAN>目录下<SPAN lang=EN-US>. </SPAN>请把<SPAN lang=EN-US> struts.jar \mystruts\WEB-INF\lib </SPAN>目录下<SPAN lang=EN-US>. <BR><BR>&lt;Context path="/mystruts" docBase="D:\www\mystruts\mystruts\mystruts" debug="0" privileged="true"&gt; <BR><BR>&lt;Resource name="jdbc/TestDB" <BR>auth="Container" <BR>type="javax.sql.DataSource"/&gt; <BR><BR>&lt;ResourceParams name="jdbc/TestDB"&gt; <BR>&lt;parameter&gt; <BR>&lt;name&gt;factory&lt;/name&gt; <BR>&lt;value&gt;org.apache.commons.dbcp.BasicDataSourceFactory&lt;/value&gt; <BR>&lt;/parameter&gt; <BR><BR>&lt;parameter&gt; <BR>&lt;name&gt;maxActive&lt;/name&gt; <BR>&lt;value&gt;10&lt;/value&gt; <BR>&lt;/parameter&gt; <BR><BR>&lt;parameter&gt; <BR>&lt;name&gt;maxIdle&lt;/name&gt; <BR>&lt;value&gt;5&lt;/value&gt; <BR>&lt;/parameter&gt; <BR><BR>&lt;parameter&gt; <BR>&lt;name&gt;maxWait&lt;/name&gt; <BR>&lt;value&gt;10000&lt;/value&gt; <BR>&lt;/parameter&gt; <BR><BR>&lt;parameter&gt; <BR>&lt;name&gt;username&lt;/name&gt; <BR>&lt;value&gt;sa&lt;/value&gt; <BR>&lt;/parameter&gt; <BR>&lt;parameter&gt; <BR>&lt;name&gt;password&lt;/name&gt; <BR>&lt;value&gt;test&lt;/value&gt; <BR>&lt;/parameter&gt; <BR><BR>&lt;parameter&gt; <BR>&lt;name&gt;driverClassName&lt;/name&gt; <BR>&lt;value&gt;net.sourceforge.jtds.jdbc.Driver&lt;/value&gt; <BR>&lt;/parameter&gt; <BR><BR>&lt;parameter&gt; <BR>&lt;name&gt;url&lt;/name&gt; <BR>&lt;value&gt;jdbc:jtds:sqlserver://192.168.10.223:1433/mystruts&lt;/value&gt; <BR>&lt;/parameter&gt; <BR>&lt;/ResourceParams&gt; <BR>&lt;/Context&gt; <BR><BR>WEB-INF/web.xml (</SPAN>加入<SPAN lang=EN-US>struts</SPAN>标记库的支持<SPAN lang=EN-US>) <BR><BR>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <BR>&lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"&gt; <BR>&lt;web-app&gt; <BR>&lt;servlet&gt; <BR>&lt;servlet-name&gt;action&lt;/servlet-name&gt; <BR>&lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt; <BR>&lt;init-param&gt; <BR>&lt;param-name&gt;debug&lt;/param-name&gt; <BR>&lt;param-value&gt;2&lt;/param-value&gt; <BR>&lt;/init-param&gt; <BR>&lt;init-param&gt; <BR>&lt;param-name&gt;config&lt;/param-name&gt; <BR>&lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt; <BR>&lt;/init-param&gt; <BR>&lt;load-on-startup&gt;2&lt;/load-on-startup&gt; <BR>&lt;/servlet&gt; <BR>&lt;servlet-mapping&gt; <BR>&lt;servlet-name&gt;action&lt;/servlet-name&gt; <BR>&lt;url-pattern&gt;*.do&lt;/url-pattern&gt; <BR>&lt;/servlet-mapping&gt; <BR>&lt;taglib&gt; <BR>&lt;taglib-uri&gt;/WEB-INF/struts-bean.tld&lt;/taglib-uri&gt; <BR>&lt;taglib-location&gt;/WEB-INF/struts-bean.tld&lt;/taglib-location&gt; <BR>&lt;/taglib&gt; <BR>&lt;taglib&gt; <BR>&lt;taglib-uri&gt;/WEB-INF/struts-html.tld&lt;/taglib-uri&gt; <BR>&lt;taglib-location&gt;/WEB-INF/struts-html.tld&lt;/taglib-location&gt; <BR>&lt;/taglib&gt; <BR>&lt;taglib&gt; <BR>&lt;taglib-uri&gt;/WEB-INF/struts-logic.tld&lt;/taglib-uri&gt; <BR>&lt;taglib-location&gt;/WEB-INF/struts-logic.tld&lt;/taglib-location&gt; <BR>&lt;/taglib&gt; <BR>&lt;taglib&gt; <BR>&lt;taglib-uri&gt;/WEB-INF/struts-template.tld&lt;/taglib-uri&gt; <BR>&lt;taglib-location&gt;/WEB-INF/struts-template.tld&lt;/taglib-location&gt; <BR>&lt;/taglib&gt; <BR>&lt;/web-app&gt;</SPAN>（未完待续）</SPAN><img src ="http://www.blogjava.net/Areschina/aggbug/19951.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Areschina/" target="_blank">Areschina</a> 2005-11-15 20:33 <a href="http://www.blogjava.net/Areschina/articles/19951.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的struts应用开发（2）</title><link>http://www.blogjava.net/Areschina/articles/19949.html</link><dc:creator>Areschina</dc:creator><author>Areschina</author><pubDate>Tue, 15 Nov 2005 12:32:00 GMT</pubDate><guid>http://www.blogjava.net/Areschina/articles/19949.html</guid><wfw:comment>http://www.blogjava.net/Areschina/comments/19949.html</wfw:comment><comments>http://www.blogjava.net/Areschina/articles/19949.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Areschina/comments/commentRss/19949.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Areschina/services/trackbacks/19949.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">简单的</SPAN><SPAN lang=EN-US>struts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用开发（</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US><BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第二步</SPAN><SPAN lang=EN-US>: </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置数据库</SPAN><SPAN lang=EN-US> <BR><BR>1.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">首先创建数据联接</SPAN><SPAN lang=EN-US>bean, </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并打包到</SPAN><SPAN lang=EN-US> ConnectionPool, </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它将从我们配置的联接池中取得可用联接</SPAN><SPAN lang=EN-US>. <BR><BR>// Java Document <BR>package ConnectionPool; <BR>import javax.naming.*; <BR>import javax.sql.*; <BR>import java.sql.*; <BR>import java.io.*; <BR>import java.util.*; <BR><BR>public class getDbConnection { <BR><BR>Connection conn; <BR>Statement stmt; <BR>ResultSet rs=null; <BR><BR>String foo = "Not Connected"; <BR>int bar = -1; <BR><BR>public getDbConnection() { <BR>try{ <BR>Context ctx = new InitialContext(); <BR>if(ctx == null ) <BR>throw new Exception("Boom - No Context"); <BR><BR>DataSource ds = <BR>(DataSource)ctx.lookup( <BR>"java:comp/env/jdbc/TestDB"); <BR><BR>if (ds != null) { <BR>conn = ds.getConnection(); <BR><BR>} <BR>} <BR>catch(Exception e) { <BR>e.printStackTrace(); <BR>} <BR>} <BR><BR>public Connection getCon() <BR>{ <BR>return conn; <BR>} <BR><BR><BR>public void d_close() throws SQLException <BR>{ <BR>if (rs != null) { <BR>try { rs.close(); } catch (SQLException e) { ; } <BR>rs = null; <BR>} <BR>if (stmt != null) { <BR>try { stmt.close(); } catch (SQLException e) { ; } <BR>stmt = null; <BR>} <BR>if (conn != null) { <BR>try { conn.close(); } catch (SQLException e) { ; } <BR>conn = null; <BR>} <BR><BR>} <BR><BR>protected void finalize() throws Throwable <BR>{ <BR>try { d_close(); } catch (SQLException e) { ; } <BR>} <BR><BR>} <BR><BR>2.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">创建数据库</SPAN><SPAN lang=EN-US>. <BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数据库名</SPAN><SPAN lang=EN-US>: mystruts <BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">部门表</SPAN><SPAN lang=EN-US>: mydep <BR><BR>_______________________________________ <BR>dep_id dep_name <BR>_______________________________________ <BR>1 dep1 <BR>2 dep2 <BR>3 dep3 <BR>4 dep4 <BR>_______________________________________ <BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用户表</SPAN><SPAN lang=EN-US>: myuser <BR>______________________________________________ <BR>user_id user_name dep tel <BR>______________________________________________ <BR>1 jack 1 0769-2454042 <BR>2 max 2 0769-2454043 <BR>______________________________________________ <BR><BR>(</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注</SPAN><SPAN lang=EN-US>: </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以上字段为了测试方便</SPAN><SPAN lang=EN-US>. </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">全部使用字符型</SPAN><SPAN lang=EN-US>) <BR><BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第三步</SPAN><SPAN lang=EN-US>: </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">创建</SPAN><SPAN lang=EN-US>ActionForm (userActionForm.java) <BR><BR>package mystruts; //</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">请打包到</SPAN><SPAN lang=EN-US>mystruts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下</SPAN><SPAN lang=EN-US>. <BR><BR>import org.apache.struts.action.*; <BR>import javax.servlet.http.*; <BR><BR>public class userActionForm extends ActionForm { <BR>private String action="add"; <BR>private String dep; <BR>private String tel; <BR>private String user_id; <BR>private String user_name; <BR>public String getAction() { <BR>return action; <BR>} <BR>public void setAction(String action) { <BR>this.action = action; <BR>} <BR>public String getDep() { <BR>return dep; <BR>} <BR>public void setDep(String dep) { <BR>this.dep = dep; <BR>} <BR>public String getTel() { <BR>return tel; <BR>} <BR>public void setTel(String tel) { <BR>this.tel = tel; <BR>} <BR>public String getUser_id() { <BR>return user_id; <BR>} <BR>public void setUser_id(String user_id) { <BR>this.user_id = user_id; <BR>} <BR>public String getUser_name() { <BR>return user_name; <BR>} <BR>public void setUser_name(String user_name) { <BR>this.user_name = user_name; <BR>} <BR>public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { <BR><BR>return null; <BR>} <BR>public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { <BR>} <BR>} </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（未完待续）</SPAN></P><img src ="http://www.blogjava.net/Areschina/aggbug/19949.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Areschina/" target="_blank">Areschina</a> 2005-11-15 20:32 <a href="http://www.blogjava.net/Areschina/articles/19949.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的struts应用开发（3）</title><link>http://www.blogjava.net/Areschina/articles/19948.html</link><dc:creator>Areschina</dc:creator><author>Areschina</author><pubDate>Tue, 15 Nov 2005 12:31:00 GMT</pubDate><guid>http://www.blogjava.net/Areschina/articles/19948.html</guid><wfw:comment>http://www.blogjava.net/Areschina/comments/19948.html</wfw:comment><comments>http://www.blogjava.net/Areschina/articles/19948.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Areschina/comments/commentRss/19948.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Areschina/services/trackbacks/19948.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">简单的</SPAN><SPAN lang=EN-US>struts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用开发（</SPAN><SPAN lang=EN-US>3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US><BR></SPAN><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第四步</SPAN><SPAN lang=EN-US>:</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立数据库操作对象</SPAN><SPAN lang=EN-US> (</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">完成对表的增删修改与查询</SPAN><SPAN lang=EN-US>) <BR><BR>package mystruts; <BR><BR>import java.sql.*; <BR>import ConnectionPool.*; <BR>import java.util.*; <BR><BR>public class userdao { <BR>getDbConnection db=null; <BR>Connection con=null; <BR><BR>public userdao() { <BR>} <BR>//------------------------------------------------------------------- <BR>public void userInsert(userActionForm uaf1) <BR>{ <BR>db=new getDbConnection(); <BR>con=db.getCon(); <BR>userActionForm uaf=uaf1; <BR>PreparedStatement ps = null; <BR>String sql="insert into myuser (user_id,user_name,dep,tel) values(?,?,?,?)"; <BR>try { <BR><BR>ps = con.prepareStatement(sql); <BR>ps.setString(1,uaf.getUser_id()); <BR>ps.setString(2,uaf.getUser_name()); <BR>ps.setString(3,uaf.getDep()); <BR>ps.setString(4,uaf.getTel()); <BR>ps.executeUpdate(); <BR>} <BR>catch (SQLException e) <BR>{ <BR>System.out.println("sql error"); <BR>} <BR>finally <BR>{ <BR>try{ <BR>con.close(); <BR>db.d_close(); <BR>} <BR>catch(Exception e) {} <BR>} <BR>} <BR>//--------------------------------------------- <BR>public void userUpdate(userActionForm uaf1) <BR>{ <BR>db=new getDbConnection(); <BR>con=db.getCon(); <BR>userActionForm uaf=uaf1; <BR>PreparedStatement ps = null; <BR>String sql="update myuser set user_name=?,dep=?,tel=? where user_id=?"; <BR>try { <BR><BR>ps = con.prepareStatement(sql); <BR>ps.setString(1,uaf.getUser_name()); <BR>ps.setString(2,uaf.getDep()); <BR>ps.setString(3,uaf.getTel()); <BR>ps.setString(4,uaf.getUser_id()); <BR>ps.executeUpdate(); <BR>} <BR>catch (SQLException e) <BR>{ <BR>System.out.println("sql error"); <BR>} <BR>finally <BR>{ <BR>try{ <BR>con.close(); <BR>db.d_close(); <BR>} <BR>catch(Exception e) {} <BR>} <BR>} <BR>//--------------------------------------------- <BR>public userActionForm getUser(String key) <BR>{ <BR>db=new getDbConnection(); <BR>con=db.getCon(); <BR>ResultSet rs=null; <BR>userActionForm uaf=new userActionForm(); <BR>PreparedStatement ps = null; <BR>String sql="select * from myuser where user_id=?"; <BR>try { <BR>ps = con.prepareStatement(sql); <BR>ps.setString(1,key.trim()); <BR>rs=ps.executeQuery(); <BR>if(rs.next()) <BR>{ <BR>uaf.setUser_id(rs.getString("user_id")); <BR>uaf.setUser_name(rs.getString("user_name")); <BR>uaf.setDep(rs.getString("dep")); <BR>uaf.setTel(rs.getString("tel")); <BR>uaf.setAction("edit"); <BR>} <BR>} <BR>catch (SQLException e) <BR>{ <BR>System.out.println("sql error"); <BR>} <BR>finally <BR>{ <BR>try{ <BR>con.close(); <BR>db.d_close(); <BR>} <BR>catch(Exception e) {} <BR>} <BR>System.out.println("mod"+key); <BR>return uaf; <BR>} <BR>//---------------------------------------- <BR>public void delUser(String key) <BR>{ <BR>db=new getDbConnection(); <BR>con=db.getCon(); <BR>PreparedStatement ps = null; <BR>String sql="delete from myuser where user_id=?"; <BR>try { <BR>ps = con.prepareStatement(sql); <BR>ps.setString(1,key.trim()); <BR>ps.executeUpdate(); <BR>} <BR>catch (SQLException e) <BR>{ <BR>System.out.println("sql error"); <BR>} <BR>finally <BR>{ <BR>try{ <BR>con.close(); <BR>db.d_close(); <BR>} <BR>catch(Exception e) {} <BR>} <BR>System.out.println("del"+key); <BR>} <BR>//---------------------------------- <BR>public Collection getAlluser() <BR>{ <BR>db=new getDbConnection(); <BR>con=db.getCon(); <BR>ResultSet rs=null; <BR>userActionForm uaf=new userActionForm(); <BR>PreparedStatement ps = null; <BR><BR>ArrayList rslist = new ArrayList(); <BR><BR>String sql="select * from myuser u,mydep d where u.dep=d.dep_id"; <BR>try { <BR>ps = con.prepareStatement(sql); <BR>rs=ps.executeQuery(); <BR>while(rs.next()) <BR>{ <BR>HashMap rscol = new HashMap(); <BR>rscol.put("user_id",rs.getString("user_id")); <BR>rscol.put("user_name",rs.getString("user_name")); <BR>rscol.put("dep",rs.getString("dep")); <BR>rscol.put("dep_name",rs.getString("dep_name")); <BR>rscol.put("tel",rs.getString("tel")); <BR>rslist.add(rscol); <BR>} <BR>} <BR>catch (SQLException e) <BR>{ <BR>System.out.println("sql error"); <BR>} <BR>finally <BR>{ <BR>try{ <BR>con.close(); <BR>db.d_close(); <BR>} <BR>catch(Exception e) {} <BR>} <BR>return rslist; <BR>} <BR>//---------------------------------- <BR>} </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（未完待续）</SPAN></P><img src ="http://www.blogjava.net/Areschina/aggbug/19948.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Areschina/" target="_blank">Areschina</a> 2005-11-15 20:31 <a href="http://www.blogjava.net/Areschina/articles/19948.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的struts应用开发（4）</title><link>http://www.blogjava.net/Areschina/articles/19947.html</link><dc:creator>Areschina</dc:creator><author>Areschina</author><pubDate>Tue, 15 Nov 2005 12:30:00 GMT</pubDate><guid>http://www.blogjava.net/Areschina/articles/19947.html</guid><wfw:comment>http://www.blogjava.net/Areschina/comments/19947.html</wfw:comment><comments>http://www.blogjava.net/Areschina/articles/19947.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Areschina/comments/commentRss/19947.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Areschina/services/trackbacks/19947.html</trackback:ping><description><![CDATA[<SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">简单的</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">struts</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用开发（</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">4</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US><BR><BR></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第五步</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">:</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">Action (userAction.java) <BR><BR></FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里我们将建产两个</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">Action . <BR><BR>userAction.java </FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将完成以下工作</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">. <BR>1.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">添加</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">(</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">前期数据准备</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">. </FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">主是提取部门资料</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并传递给</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">adduser.jsp) <BR>2.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">修改</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">(</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">前期数据准备</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">) <BR>3.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">删除</SPAN><SPAN lang=EN-US><FONT face="Times New Roman"> <BR>4.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">查看所有用户资料</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">. <BR><BR>user1Action.java </FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将完成以下工作</SPAN><SPAN lang=EN-US><FONT face="Times New Roman"> <BR>1.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">添加用户</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">(</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">myuser</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表操作</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">) <BR>2.</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">修改用户</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">(</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">myuser</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表操作</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">) <BR><BR>package mystruts; <BR><BR>import org.apache.struts.action.*; <BR>import javax.servlet.http.*; <BR>import mystruts.*; <BR>import java.util.*; <BR>import java.sql.*; <BR>import ConnectionPool.*; <BR><BR>public class userAction extends Action { <BR>public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception <BR>{ <BR>userdao dao=new userdao(); <BR>HttpServletRequest request=httpServletRequest; <BR>String action; <BR>if(request.getParameter("action").equals("") || request.getParameter("action")==null) <BR>{ <BR>action="add"; <BR>} <BR>else <BR>{ <BR>action=request.getParameter("action"); <BR>} <BR>if(action.equals("add")) <BR>{ <BR>request.setAttribute("dep",this.getDep()); <BR>return (actionMapping.findForward("add")); <BR>} <BR>if(action.equals("edit")) <BR>{ <BR>String key=request.getParameter("key"); <BR>request.setAttribute("dep",this.getDep()); <BR>request.setAttribute("userActionForm",dao.getUser(key)); <BR>return (actionMapping.findForward("add")); <BR>} <BR>if(action.equals("del")) <BR>{ <BR>String key=request.getParameter("key"); <BR>dao.delUser(key); <BR>return (actionMapping.findForward("delview")); <BR>} <BR>if(action.equals("view")) <BR>{ <BR>request.setAttribute("rs",dao.getAlluser()); <BR>return (actionMapping.findForward("view")); <BR>} <BR><BR>return null; <BR>} <BR>//--------------------------------------------- <BR>public Collection getDep() <BR>{ <BR>getDbConnection db=new getDbConnection(); <BR>Connection con=db.getCon(); <BR>ResultSet rs=null; <BR><BR>PreparedStatement ps = null; <BR><BR>ArrayList rslist = new ArrayList(); <BR><BR>String sql="select * from mydep"; <BR>try { <BR>ps = con.prepareStatement(sql); <BR>rs=ps.executeQuery(); <BR>while(rs.next()) <BR>{ <BR>HashMap rscol = new HashMap(); <BR>rscol.put("id",rs.getString("dep_id")); <BR>rscol.put("name1",rs.getString("dep_name")); <BR>rslist.add(rscol); <BR>} <BR>} <BR>catch (SQLException e) <BR>{ <BR>System.out.println("sql error"); <BR>} <BR>finally <BR>{ <BR>try{ <BR>con.close(); <BR>db.d_close(); <BR>} <BR>catch(Exception e) {} <BR>} <BR>return rslist; <BR>} <BR>} <BR><BR><BR><BR>package mystruts; <BR><BR>import org.apache.struts.action.*; <BR>import javax.servlet.http.*; <BR><BR>public class user1Action extends Action { <BR>public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception <BR>{ <BR>userActionForm uaf = (userActionForm) actionForm; <BR>if(uaf.getAction().equals("add")) <BR>{ <BR>new userdao().userInsert(uaf); <BR>return (actionMapping.findForward("view")); <BR>} <BR>if(uaf.getAction().equals("edit")) <BR>{ <BR>new userdao().userUpdate(uaf); <BR>return (actionMapping.findForward("view")); <BR>} <BR>return null; <BR>} <BR>}</FONT></SPAN></P></SPAN><img src ="http://www.blogjava.net/Areschina/aggbug/19947.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Areschina/" target="_blank">Areschina</a> 2005-11-15 20:30 <a href="http://www.blogjava.net/Areschina/articles/19947.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>