|
ballList放入session
//do what you wish with myConnection } catch (SQLException sqle) { getServlet().log("Connection.process", sqle); } finally { //enclose this in a finally block to make //sure the connection is closed if(connection!=null) try { connection.close(); } catch (SQLException e) { getServlet().log("Connection.close", e); } }
return (mapping.findForward("success")); } }
action.xml和struts-config.xml文件的配置
这里将不再阐述,请参考第一篇《利用Struts结合Jbuilder7、MySql建立Web站点(1)--连接数据库》
struts-config.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<!-- This is the Struts configuration file for the example application, using the proposed new syntax.
NOTE: You would only flesh out the details in the "form-bean" declarations if you had a generator tool that used them to create the corresponding Java classes for you. Otherwise, you would need only the "form-bean" element itself, with the corresponding "name" and "type" attributes. -->
<struts-config>
<!-- ========== Data Source Configuration =============================== --> <data-sources> <data-source> <set-property property="autoCommit" value="false"/> <set-property property="description" value="Data Source Configuration"/> <set-property property="driverClass" value="org.gjt.mm.mysql.Driver"/> <set-property property="maxCount" value="200"/> <set-property property="minCount" value="20"/> <set-property property="password" value="sailing"/> <set-property property="url" value="jdbc:mysql://localhost/gdmovie"/> <set-property property="user" value="DateBase"/> </data-source> </data-sources>
<!-- ========== Form Bean Definitions =================================== --> <form-beans>
<!-- Football form bean --> <form-bean name="footballForm" type="vod.model.footballForm"/>
<!-- Fun form bean --> <form-bean name="funForm" type="vod.model.funForm"/>
<!-- Movie form bean --> <form-bean name="movieForm" type="vod.model.movieForm"/>
<!-- MTV form bean --> <form-bean name="mtvForm" type="vod.model.mtvForm"/>
</form-beans>
<!-- ========== Global Forward Definitions ============================== --> <global-forwards> <forward name="welcome" path="/welcome.do"/> </global-forwards>
<!-- ========== Action Mapping Definitions ============================== --> <action-mappings>
<!-- Enter into welcome Page --> <action path="/welcome" type="vod.controller.DisplayWelcomeAction"> <forward name="success" path="/welcome.jsp"/> </action>
<!-- Enter into morefootball Page --> <action path="/morefootball" type="vod.controller.MoreFootballAction"> <forward name="success" path="/morefootball.jsp"/> </action>
<!-- Enter into viewfootball Page --> <action path="/viewfootball" type="vod.controller.ViewFootballAction"> <forward name="success" path="/viewfootball.jsp"/> </action>
</action-mappings>
</struts-config> action.xml:
<action-mappings>
<!-- Global Forward Declarations --> <forward name="welcome" path="/welcome.do"/>
<!-- Process a user logon --> <action path="/welcome" actionClass="vod.controller.DisplayWelcomeAction"> <forward name="success" path="/welcome.jsp"/> </action> <action path="/morefootball" actionClass="vod.controller.MoreFootballAction"> <forward name="success" path="/morefootball.jsp"/> </action> <action path="/viewfootball" actionClass="vod.controller.ViewFootballAction"> <forward name="success" path="/viewfootball.jsp"/> </action>
</action-mappings>
Jsp页面
welcome.jsp:将在这个页中加入更多足球这个链接,并且调用MoreFootballAction并且指定取第一页。
代码如下:
<%@ page contentType="text/html; charset=GB2312" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <html> <head> <title> welcome </title> </head> <body> <table width="694" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="70"><div align="center">id</div></td> <td width="110"><div align="center">footname</div></td> <td width="82"><div align="center">viewURL</div></td> <td width="92"><div align="center">downURL</div></td> <td width="48"><div align="center">clicks</div></td> <td width="41"><div align="center">sort</div></td> <td width="40"><div align="center">intro</div></td> <td width="66"><div align="center">commend</div></td> <td width="61"><div align="center">date</div></td> <td width="33"><div align="center">bad</div></td> <td width="51"><div align="center">length</div></td> </tr> <logic:iterate id="football" name="footballTop"> <tr> <td><div align="center"><bean:write name="football" property="id"/></div></td> <td><div align="center"><bean:write name="football" property="footballName"/></div></td> <td><div align="center"><bean:write name="football" property="viewURL"/></div></td> <td><div align="center"><bean:write name="football" property="downURL"/></div></td> <td><div align="center"><bean:write name="football" property="clicks"/></div></td> <td><div align="center"><bean:write name="football" property="sort"/></div></td> <td><div align="center"><bean:write name="football" property="intro"/></div></td> <td><div align="center"><bean:write name="football" property="commend"/></div></td> <td><div align="center"><bean:write name="football" property="date"/></div></td> <td><div align="center"><bean:write name="football" property="bad"/></div></td> <td><div align="center"><bean:write name="football" property="length"/></div></td> </tr> </logic:iterate> </table> <html:link page="/morefootball.do?page=1">更多足球</html:link> <br> <table width="694" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="70"><div align="center">id</div></td> <td width="110"><div align="center">funname</div></td> <td width="82"><div align="center">viewURL</div></td> <td width="92"><div align="center">downURL</div></td> <td width="48"><div align="center">clicks</div></td> <td width="41"><div align="center">sort</div></td> <td width="40"><div align="center">intro</div></td> <td width="66"><div align="center">commend</div></td> <td width="61"><div align="center">date</div></td> <td width="33"><div align="center">bad</div></td> <td width="51"><div align="center">length</div></td> </tr> <logic:iterate id="fun" name="funTop"> <tr> <td><div align="center"><bean:write name="fun" property="id"/></div></td> <td><div align="center"><bean:write name="fun" property="funName"/></div></td> <td><div align="center"><bean:write name="fun" property="viewURL"/></div></td> <td><div align="center"><bean:write name="fun" property="downURL"/></div></td> <td><div align="center"><bean:write name="fun" property="clicks"/></div></td> <td><div align="center"><bean:write name="fun" property="sort"/></div></td> <td><div align="center"><bean:write name="fun" property="intro"/></div></td> <td><div align="center"><bean:write name="fun" property="commend"/></div></td> <td><div align="center"><bean:write name="fun" property="date"/></div></td> <td><div align="center"><bean:write name="fun" property="bad"/></div></td> <td><div align="center"><bean:write name="fun" property="length"/></div></td> </tr> </logic:iterate> </table> <br> <table width="694" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="70"><div align="center">id</div></td> <td width="110"><div align="center">moviename</div></td> <td width="82"><div align="center"上一页 [1] [2] [3] 下一页 [MySql]PHP存取 Mysql 数据乱码终极解决方案 [MySql]解决Table xxx is marked as crashed and should … [MySql][MySQL]快速解决"is marked as crashed and shoul… [MySql]MySQL DELETE语法用法详解 [MySql]mysql中时间日期格式化 [MySql]修改mysql导入文件大小限制 [其他]MySql常用命令大全 [Web开发]把ACCESS的数据导入到Mysql中的方法详解 [MySql]解决mysql 1040错误Too many connections的方法 [聊天工具]Gmail推出新功能:Web Clip__天极Yesky
|