Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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ÂÒÂë³õ¼¶½â¾ö·½°¸

×î»ù±¾µÄÂÒÂëÎÊÌâ
Õâ¸öÂÒÂëÎÊÌâÊÇ×î¼òµ¥µÄÂÒÂëÎÊÌâ¡£Ò»°ãлá³öÏÖ¡£¾ÍÊÇÒ³Ãæ±àÂë²»Ò»Öµ¼ÖµÄÂÒÂë¡£
Html´úÂ룺
£¼%@ page language="java" pageEncoding="UTF-8"%£¾ 
£¼%@ page contentType="text/html;charset=iso8859-1"%£¾ 
£¼html£¾ 
£¼head£¾ 
£¼title ......

Html/Jsp³£ÓõÄÒ³ÃæÌøת·½·¨

µÚÒ»ÖÖ£º
<script language="javascript" type="text/javascript">
    window.location.href="login.jsp?backurl="+window.location.href;
</script>
µÚ¶þÖÖ£º
<script language="javascript">
    alert("·µ»Ø");
    window.history.back ......

JSPÖÐÖ±½Óµ÷ÓÃSpring½Ó¹ÜµÄJAVABEAN

<%
    ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
    List stafflist = ((StaffDAO)ctx.getBean("StaffDAO")).findAll();
    request.setAttribute("stafflist",stafflist);
%> ......

JSPÖбêÇ©¿âµÄÉîÈëÑо¿


±êÇ©¿âTaglib
±êÇ©±»¶¨ÒåºÍ·Ö²¼ÔÚÒ»¸ö³ÆΪ±êÇ©¿âµÄ½á¹¹ÖУ¬Ò»¸ö±êÇ©¿âÊÇÓÉÔªÐÅÏ¢ºÍÀà×é³ÉµÄ¼¯ºÏ£º
1.±êÇ©´¦ÀíÆ÷£ºÊµÏÖ¶¨ÖƱêÇ©¹¦ÄܵÄJavaÀà¡£
2.±êÇ©¸½¼ÓÐÅÏ¢£¨TEI£©£ºÏòJSPÈÝÆ÷Ìṩ±ß¼­ÒÔÈ·ÈϱêÇ©ÊôÐԺʹ´½¨±äÁ¿µÄÀà¡£
3.±êÇ©¿âÃèÊöÆ÷£¨TLD£©£ºÃèÊöµ¥¸ö±êÇ©ºÍÕû¸ö±êÇ©¿âÊôÐÔµÄXMLÎĵµ¡£
±êÇ©´¦ÀíÆ÷ºÍ±êÇ©¸½¼ÓÐÅÏ¢Ðè ......

java web¿ª·¢ÖУ¬ÈçºÎ²é¿´JSPºÍServlet°æ±¾

java web¿ª·¢ÖУ¬ÈçºÎ²é¿´JSPºÍServlet°æ±¾
2008-12-10 09:00
ÎÒÃÇÔÚjava web¿ª·¢µÄ¹ý³ÌÖУ¬ÓÐʱÔÚ×ÊÁÏÉÏ¿ÉÄÜ»áÌáµ½»·¾³ËùÒªÖ§³ÖµÄJSP£¬Servlet°æ±¾¡£Èç¹û°æ±¾µÍ¾Í¿ÉÄܳöÏÖ²âÊÔ´íÎó¡£
·½·¨£º´ò¿ªtomcatµÄcommon\lib Ŀ¼Ï£¬ÓÐÁ½¸öJARÎļþ£º jsp-api.jar servlet-api.jar ¡£Èç¹ûûÓУ¬ÄÇ¿ÉÄÜÊÇÄãûÓÐÌí¼Ó½øÀ´¡£½âѹÕâÁ½¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ