转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 数据库 >> MySql >> 正文
利用Struts结合Jbuilder7、MySql建立Web站点(2)--分页显示         ★★★★

利用Struts结合Jbuilder7、MySql建立Web站点(2)--分页显示

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2963 更新时间:2009/4/22 20:48:46
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
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Sql Server  · MySql
    · Access  · ORACLE
    · SyBase  · 其他
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台