一切都是那么的措手不及
你來的那么突然
令我一點防備都沒有
我對你的到來很無奈
但我又不得不好好待你
你是我的眼中釘
我的手中刺
我發誓要殺掉你
不讓你再禍害其他人
我在努力地做著我該做的事
天啊 又出bug了
posted @ 2009-09-26 15:54 BBT_soft 閱讀(142) | 評論 (0) | 編輯 收藏
一切都是那么的措手不及
你來的那么突然
令我一點防備都沒有
我對你的到來很無奈
但我又不得不好好待你
你是我的眼中釘
我的手中刺
我發誓要殺掉你
不讓你再禍害其他人
我在努力地做著我該做的事
天啊 又出bug了
posted @ 2009-09-26 15:54 BBT_soft 閱讀(142) | 評論 (0) | 編輯 收藏
163 smtp.163.com pop.163.com
126 smtp.126.com pop3.126.com
188 smtp.188.com pop3.188.com
yeah smtp.yeah.net pop3.yeah.net
sina smtp.sina.com pop.sina.com
qq smtp.qq.com pop.qq.com
yahoo smtp.mail.yahoo.com.cn pop.mail.yahoo.com.cn yahoo前提是開通來信提醒業務
yahoo smtp.mail.yahoo.cn pop.mail.yahoo.cn
google smtp.gmail.com pop.gmail.com
tom smtp.tom.com pop.tom.com
sogou smtp.mail.sogou.com pop3.mail.sogou.com
sohu smtp.sohu.com pop3.sohu.com
139 smtp.139.com pop.139.com
china smtp.china.com pop.china.com 中華網郵箱
21CN smtp.21cn.net pop3:pop.21cn.net 商務郵箱服務器
smtp.21cn.com pop3:pop.21cn.com 經濟郵箱服務器
smtp.21cn.com pop3:pop.21cn.com 免費郵箱服務器
posted @ 2009-08-08 12:42 BBT_soft 閱讀(2720) | 評論 (4) | 編輯 收藏
《think in java》中有這么一段話:
如果想比較兩個對象的實際內容是否相同,又該如何操作呢?此時,必須使用所有對象都使用的特殊方法equals()。但這個方法不適用于"基本類型",基本類型直接使用==和!=即可。如:
Integer n1 = new Integer(47);
Integer n2 = new Integer(47);
System.out.println(ne.equals(n2));
正如我們預計的那樣,此時得到的結果是true。但事實上并不總是這么簡單!假設您創建了自己的類,像下面這樣:
class Value{
int i;
}
public class Test{
public static void main(String[] args){
Value v1 = new Value();
Value v2 = new Value();
System.out.println(v1.equals(v2));
}
}
此時的結果又變回了false!
這是由于equals()的默認行為是比較引用。所以除非在自己的新類中重載equals()方法,否則不可能表現出我們希望的行為。
大多數Java類庫都實現了用來比較對象內容的equals()方法,而非比較對象引用的equals()方法。
個人理解:equals()默認行為是比較引用,只是現在絕大多數Java類庫都實現了用來比較對象內容的equals()方法,而并沒有實現比較對象引用的equals()方法。所以現在說equals()比較的是內容,如果自己的類實現比較對象引用的equals()方法,也可以說equals()比較對象的引用,只是實現問題。
posted @ 2009-08-08 12:38 BBT_soft 閱讀(2053) | 評論 (6) | 編輯 收藏
由于我用的是struts框架,就拿整個項目介紹:
1.首先把jstl的兩個常用包jstl.jar、standard.jar加載到環境中
2.Action代碼:(整個過程不需要了解,這兒方法就是返回一個封裝Students對象的list,然后request.setAttribute("list", list)起來)
public ActionForward selectStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
StudentForm studentForm = (StudentForm) form;
DBConnection dbconn = new DBConnection();
Connection conn = dbconn.getConnection();
StudentServiceFactory serviceFactory = new StudentServiceFactory();
List list = serviceFactory.getStudentService().selectStudent(conn);
request.setAttribute("list", list);
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
return mapping.findForward("show");
}
3.show.jsp頁面:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>//這三句很重要
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'show.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
查詢結果如下: <br>
<table>
<tr>
<td>ID</td>
<td>姓名</td>
</tr>
<c:forEach items="${list}" var="student">// items為list的一個迭代器,list為Action中傳遞過來的list,student為Student類對象
<tr>
<td>${student.id }</td>//輸出student的id屬性
<td>${student.name }</td>//輸出student的name屬性
</tr>
</c:forEach>
<logic:iterate id="li" name="list" type="vo.Student">//id為自定義的名字,name為Action中傳過來的list,type為實體類,包括完整路徑,這里是vo.Student
<tr>
<td><bean:write name="li" property="id"/></td>//name為邏輯名,和logic:iterate id="li"中的id對應,property為實體類中真正的屬性
<td><bean:write name="li" property="name"/></td>
<td><a href="student.do?method=deleteStudent&id=<bean:write name="li" property="id"/>">刪除</a></td>
</tr>
</logic:iterate>
</table>
<a href="student.jsp">返回</a>
</body>
</html>
在JSP頁面引入Struts標簽庫的時候有所不同:
struts1.3的為:
<%@ taglib uri=" <%@ taglib uri=" <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>或者<%@ taglib uri="
posted @ 2009-08-02 16:21 BBT_soft 閱讀(2181) | 評論 (1) | 編輯 收藏
1.在項目的WebRoot/META-INF下建context.xml文件,注意必須在該目錄下,Tomcat會自動找這個文件,Tomcat6.0以后就不用在web.xml中配置了:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<Resource
name="jdbc/test" ----------注意:test為項目名
auth="Container"----------該項為不變項
type="javax.sql.DataSource"----------該項為不變項
driverClassName="com.mysql.jdbc.Driver"----------數據庫驅動名
url="jdbc:mysql://localhost:3306/haotian?autoReconnect=true"-------url
username="root"-----用戶名
password="root"------密碼
maxActive="10" ------最大連接數
maxIdle="5" --------最大空閑連接數
maxWait="-1"/> ------最大等待毫秒數,-1為無限等待
</Context>
2.連接類:
public class DBConnection {
private Connection conn=null;
public Connection getConnection(){
//生成上下文對象,通過它可以向容器發送別名.
Context context;
try {
context = new InitialContext();
//查找對象
DataSource ds=(DataSource)context.lookup("java:comp/env/jdbc/test");//jdbc/test為配置文件中的name
//得到連接
try {
conn=ds.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
3.把MySQL5.0的驅動包放到Tomcat的lib目錄下,注意:是Tomcat的lib,而不是項目的lib。(不知道為什么會這樣,之前不用這種連接池的時候放在項目的lib中就可以連接成功,但是現在就不可以,個人認為可能是context.xml使得Tomcat找自身lib中的驅動包,而不是項目中的驅動包)
4.測試:
這里并非是在連接類里面寫個main()就可以測試成功的,如果這樣會出現下面的錯誤:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at util.DBConnection.getConnection(DBConnection.java:26)
at util.DBConnection.main(DBConnection.java:49)
所以,只有通過和前臺結合才能測試連接是否成功。
總結:
context.xml必須在項目的WebRoot/META-INF,Tomcat會自動找這個文件;
數據庫驅動包必須放在Tomcat的lib目錄下(可能是Tomcat會根據context.xml在自身的lib目錄下找驅動包);
不可以直接在連接類中寫main()測試,必須和前臺結合;
posted @ 2009-06-13 09:21 BBT_soft 閱讀(1182) | 評論 (5) | 編輯 收藏
| |||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
29 | 30 | 1 | 2 | 3 | 4 | 5 | |||
6 | 7 | 8 | 9 | 10 | 11 | 12 | |||
13 | 14 | 15 | 16 | 17 | 18 | 19 | |||
20 | 21 | 22 | 23 | 24 | 25 | 26 | |||
27 | 28 | 29 | 30 | 31 | 1 | 2 | |||
3 | 4 | 5 | 6 | 7 | 8 | 9 |