摘要: 目錄結(jié)構(gòu):
struts1的登陸以及驗(yàn)證
login.jsp
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><%@ page language="java" pageEncodin... 閱讀全文
2010年1月17日
mysqlfront連接時(shí)出現(xiàn)“程序注冊時(shí)間到期了,程序?qū)⒈幌拗圃诘J较逻\(yùn)行”這個(gè)問題時(shí),不用重裝,只需在Mysql Front 的“幫助”菜單項(xiàng)的“登記”里輸入以下Mysql Front的注冊碼即可。 在別人那里偷來的:下載一個(gè)注冊機(jī):http://www.zhaipeng.cn/ftp/MySQL-Front.5.1.KeyGen.zip 哈哈,打開應(yīng)用程序,嚇的我小心肝撲撲滴。。還帶聲音的。。 |
自動轉(zhuǎn)換規(guī)則:
byte->short->int->long->float->double->char->int
jsp復(fù)習(xí)
1.注釋和語法
2.page指令
3.在jsp中連接數(shù)據(jù)庫
4.包含指令和跳轉(zhuǎn)指令
**********1。語法*******************
<% %>:聲明變量,表達(dá)式
<%!%>:聲明常量,寫方法,還可以寫類(一般情況下不能寫)
<%=%>:輸出表達(dá)式及其他詳細(xì)
<%!%>:聲明常量,寫方法,還可以寫類(一般情況下不能寫)
<%=%>:輸出表達(dá)式及其他詳細(xì)
寫個(gè)簡單的練習(xí)哈 --- 動態(tài)打印表格
工具:myeclipse7.0+tomcat6.0
3-1.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<html>
<body>
動態(tài)打印表格
<form action="3-1.jsp" method="post">
輸入行:<input type="text" name="rows"><br>
輸入列:<input type="text" name="cols"><br>
<input type="submit" value="打印表單">
</form>
</body>
動態(tài)打印表格
<form action="3-1.jsp" method="post">
輸入行:<input type="text" name="rows"><br>
輸入列:<input type="text" name="cols"><br>
<input type="submit" value="打印表單">
</form>
</body>
</html>
3-1.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<body>
<% int row=Integer.parseInt(request .getParameter("rows"));
int cols=Integer.parseInt(request.getParameter("cols"));
%>
<table border="2" bordercolor="#eeeeee">
<%for(int i=1;i<=cols;i++){ %>
<tr>
<%for(int j=1;j<=row;j++){ %>
<td><%=i*j %></td>
<%} %>
</tr>
<%} %>
</table>
</body>
</html>
<body>
<% int row=Integer.parseInt(request .getParameter("rows"));
int cols=Integer.parseInt(request.getParameter("cols"));
%>
<table border="2" bordercolor="#eeeeee">
<%for(int i=1;i<=cols;i++){ %>
<tr>
<%for(int j=1;j<=row;j++){ %>
<td><%=i*j %></td>
<%} %>
</tr>
<%} %>
</table>
</body>
</html>
************2.page指令************************
page表示當(dāng)前的jsp頁面對象.
作用:設(shè)置MIME類型--<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ page contentType="text/html"%>
導(dǎo)包指令 <%@page import="java.util.*" %>
其他指令:錯(cuò)誤頁,禁止session,頁面的緩沖等
----------------連接數(shù)據(jù)庫mysql--------
1 <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2 <%@ page import="java.sql.*" %>
3 <%
4 String path = request.getContextPath();
5 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
6 %>
7
8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
9 <html>
10 <head>
11 <base href="<%=basePath%>">
12 </head>
21 <body>
22 <%!
23 public static final String driver="com.mysql.jdbc.Driver";
24 public static final String dburl="jdbc:mysql://localhost:3306/bbs";
25 public static final String username="root";
26 public static final String password="wszf";
27 %>
28
29 <%
30 Connection conn=null;//數(shù)據(jù)庫連接
31 PreparedStatement pst=null;//數(shù)據(jù)庫操作
32 ResultSet rs=null;//結(jié)果集
33 %>
34 <%
35 Class.forName(driver).newInstance();// 加載數(shù)據(jù)庫驅(qū)動
36 conn=DriverManager.getConnection(dburl,username,password);
37 String sql="select id,username,password from user_tb";
38 pst=conn.prepareStatement(sql);
39 rs=pst.executeQuery();
40 %>
41 <center>
42 <table border="1" width="20%" bordercolor="#aaa">
43 <tr>
44 <td>id</td>
45 <td>姓名</td>
46 <td>密碼</td>
47 </tr>
48 <%
49 while(rs.next()){
50 int id=rs.getInt(1);
51 String name=rs.getString(2);
52 String pass=rs.getString(3);
53
54 %>
55 <tr>
56 <td><%=id %></td>
57 <td><%=name %></td>
58 <td><%=pass %></td>
59 </tr>
60 <%} %>
61 <%
62 rs.close();
63 pst.close();
64 conn.close();
65 %>
66 </table>
67 </center>
68 </body>
69 </html>
70
2 <%@ page import="java.sql.*" %>
3 <%
4 String path = request.getContextPath();
5 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
6 %>
7
8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
9 <html>
10 <head>
11 <base href="<%=basePath%>">
12 </head>
21 <body>
22 <%!
23 public static final String driver="com.mysql.jdbc.Driver";
24 public static final String dburl="jdbc:mysql://localhost:3306/bbs";
25 public static final String username="root";
26 public static final String password="wszf";
27 %>
28
29 <%
30 Connection conn=null;//數(shù)據(jù)庫連接
31 PreparedStatement pst=null;//數(shù)據(jù)庫操作
32 ResultSet rs=null;//結(jié)果集
33 %>
34 <%
35 Class.forName(driver).newInstance();// 加載數(shù)據(jù)庫驅(qū)動
36 conn=DriverManager.getConnection(dburl,username,password);
37 String sql="select id,username,password from user_tb";
38 pst=conn.prepareStatement(sql);
39 rs=pst.executeQuery();
40 %>
41 <center>
42 <table border="1" width="20%" bordercolor="#aaa">
43 <tr>
44 <td>id</td>
45 <td>姓名</td>
46 <td>密碼</td>
47 </tr>
48 <%
49 while(rs.next()){
50 int id=rs.getInt(1);
51 String name=rs.getString(2);
52 String pass=rs.getString(3);
53
54 %>
55 <tr>
56 <td><%=id %></td>
57 <td><%=name %></td>
58 <td><%=pass %></td>
59 </tr>
60 <%} %>
61 <%
62 rs.close();
63 pst.close();
64 conn.close();
65 %>
66 </table>
67 </center>
68 </body>
69 </html>
70
做個(gè)BBS項(xiàng)目。把項(xiàng)目從別的機(jī)器上copy到自己機(jī)器上導(dǎo)入, 搗鼓了半天, 以為包導(dǎo)錯(cuò)了,頁面的struts2標(biāo)簽老是報(bào)錯(cuò),后來發(fā)現(xiàn)不是這的問題,然后把頁面的導(dǎo)入struts2標(biāo)簽的那句話刪了,在放上去保存下就沒事了,真郁悶啊。。。