JSP分页2
使用diasplaytag组件。
使用mysql5, 有个数据表user,字段有id, username, password。
使用displaytag需导入displaytag-1.1.jar,和
commons-logging
commons-lang
commons-collections
commons-beanutils
log4j
itext (optional, for pdf/rtf export)
然后在JSP页面中放入<%@ taglib uri="http://displaytag.sf.net " prefix="display"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="java.sql.*,java.util.*,test.User"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<mce:style type="text/css" media="all"><!--
@import url("css/screen.css");
--></mce:style><style type="text/css" media="all" mce_bogus="1"> @import url("css/screen.css");</style>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>分页测试2(使用diasplaytag组件)</title>
</head>
<%
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String password = "leng";
String url = "jdbc:mysql://localhost/test";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName(driver);
conn = DriverManager.getConnection(url, username, password);
stmt = conn.createStatement();
String sql = "select * from user order by id asc";
rs = stmt.executeQuery(sql);
List list = new ArrayList();
while(rs.next()){
User user = new User(rs.getInt("id"), rs.getString("username"), rs.getString("password"));
list.add(user);
}
request.setAttribute("list",list);
rs.close();
stmt.close();
conn.close();
%>
<body>
<center>
<display:table name="list" pagesize="4"
class="ITS" >
<display:column property="username" title="用户名" sortable="true"/>
<display:column property="
相关文档:
Jsp 连接 mySQL、Oracle 数据库备忘
2009-12-15 16:47
Jsp 环境目前最流行的是 Tomcat5.0。Tomcat5.0 自己包含一个 Web 服务器,如果是测试,就没必要把 Tomcat 与 IIS 或 Apache 集成起来。在 Tomcat 自带的 Web 服务器下可以进行 Jsp 测试。
安装 Tomcat5.0 前需要安装 JDK(如果是 Windows server ......
在线网页编辑器中最著名的是fckEditor,但他的功能太全面了,而且使用起来也不是很方便。相对而言新浪htmleditor就比较清爽,而且使用简单。新浪博客和人人网日志应该都是用的这个控件。但是htmleditor最多的是asp版本,在网站jsp版本十分稀少。通过查找我找到一个可以使用的新浪htmleditor jsp版本。下载地址为http://down ......
第一种:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
第二种:
<script language="javascript">
alert("返回");
window.history.back ......
required 是是否为必选属性
rtexprvalue的全称是 Run-time Expression Value, 它用于表示是否可以使用JSP表达式.
当在<attribute>标签里指定<rtexprvalue>true</rtexprvalue>时, 表示该自定义标签的某属性的值可以直接指定或者通过动态计算指定, example as follow:
<sql:query var="result" & ......