锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
浣犳潵鐨勯偅涔堢獊鐒?br />
浠ゆ垜涓鐐歸槻澶囬兘娌℃湁
鎴戝浣犵殑鍒版潵寰堟棤濂?br />
浣嗘垜鍙堜笉寰椾笉濂藉ソ寰呬綘
浣犳槸鎴戠殑鐪間腑閽?br />
鎴戠殑鎵嬩腑鍒?br />
鎴戝彂瑾撹鏉鎺変綘
涓嶈浣犲啀紲稿鍏朵粬浜?br />
鎴戝湪鍔姏鍦板仛鐫鎴戣鍋氱殑浜?br />
澶╁晩 鍙堝嚭bug浜?/p>
]]>
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鍓嶆彁鏄紑閫氭潵淇℃彁閱掍笟鍔?/p>
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 涓崕緗戦偖綆?/p>
21CN smtp.21cn.net pop3錛歱op.21cn.net 鍟嗗姟閭鏈嶅姟鍣?/p>
smtp.21cn.com pop3錛歱op.21cn.com 緇忔祹閭鏈嶅姟鍣?br />
smtp.21cn.com pop3錛歱op.21cn.com 鍏嶈垂閭鏈嶅姟鍣?
濡傛灉鎯蟲瘮杈冧袱涓璞$殑瀹為檯鍐呭鏄惁鐩稿悓錛屽張璇ュ浣曟搷浣滃憿錛熸鏃訛紝蹇呴』浣跨敤鎵鏈夊璞¢兘浣跨敤鐨勭壒孌婃柟娉昬quals()銆備絾榪欎釜鏂規硶涓嶉傜敤浜?鍩烘湰綾誨瀷",鍩烘湰綾誨瀷鐩存帴浣跨敤==鍜?=鍗沖彲銆傚錛?/p>
Integer n1 = new Integer(47);
Integer n2 = new Integer(47);
System.out.println(ne.equals(n2));
姝e鎴戜滑棰勮鐨勯偅鏍鳳紝姝ゆ椂寰楀埌鐨勭粨鏋滄槸true銆備絾浜嬪疄涓婂茍涓嶆繪槸榪欎箞綆鍗曪紒鍋囪鎮?font color="#993300">鍒涘緩浜嗚嚜宸辯殑綾?/font>錛屽儚涓嬮潰榪欐牱錛?br />
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));
}
}
姝ゆ椂鐨勭粨鏋滃張鍙樺洖浜唂alse錛?/p>
榪欐槸鐢變簬equals()鐨勯粯璁よ涓烘槸姣旇緝寮曠敤銆傛墍浠ラ櫎闈炲湪鑷繁鐨勬柊綾諱腑閲嶈澆equals()鏂規硶錛屽惁鍒欎笉鍙兘琛ㄧ幇鍑烘垜浠笇鏈涚殑琛屼負銆?/font>
澶у鏁癑ava綾誨簱閮藉疄鐜頒簡鐢ㄦ潵姣旇緝瀵硅薄鍐呭鐨別quals()鏂規硶錛岃岄潪姣旇緝瀵硅薄寮曠敤鐨別quals()鏂規硶銆?/font>
涓漢鐞嗚В錛歟quals()榛樿琛屼負鏄瘮杈冨紩鐢紝鍙槸鐜板湪緇濆ぇ澶氭暟Java綾誨簱閮藉疄鐜頒簡鐢ㄦ潵姣旇緝瀵硅薄鍐呭鐨別quals()鏂規硶錛岃屽茍娌℃湁瀹炵幇姣旇緝瀵硅薄寮曠敤鐨別quals()鏂規硶銆傛墍浠ョ幇鍦ㄨequals()姣旇緝鐨勬槸鍐呭錛屽鏋滆嚜宸辯殑綾誨疄鐜版瘮杈冨璞″紩鐢ㄧ殑equals()鏂規硶錛屼篃鍙互璇磂quals()姣旇緝瀵硅薄鐨勫紩鐢紝鍙槸瀹炵幇闂銆?/font>
1.棣栧厛鎶妀stl鐨勪袱涓父鐢ㄥ寘jstl.jar銆乻tandard.jar鍔犺澆鍒扮幆澧冧腑
2.Action浠g爜錛氾紙鏁翠釜榪囩▼涓嶉渶瑕佷簡瑙o紝榪欏効鏂規硶灝辨槸榪斿洖涓涓皝瑁匰tudents瀵硅薄鐨刲ist錛岀劧鍚巖equest.setAttribute("list", list)璧鋒潵錛?/p>
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欏甸潰錛?/p>
<%@ 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涓簂ist鐨勪竴涓凱浠e櫒錛宭ist涓篈ction涓紶閫掕繃鏉ョ殑list錛宻tudent涓篠tudent綾誨璞?br />
<tr>
<td>${student.id }</td>//杈撳嚭student鐨刬d灞炴?br />
<td>${student.name }</td>//杈撳嚭student鐨刵ame灞炴?br />
</tr>
</c:forEach>
<logic:iterate id="li" name="list" type="vo.Student">//id涓鴻嚜瀹氫箟鐨勫悕瀛楋紝name涓篈ction涓紶榪囨潵鐨刲ist錛宼ype涓哄疄浣撶被錛屽寘鎷畬鏁磋礬寰勶紝榪欓噷鏄痸o.Student
<tr>
<td><bean:write name="li" property="id"/></td>//name涓洪昏緫鍚嶏紝鍜宭ogic:iterate id="li"涓殑id瀵瑰簲錛宲roperty涓哄疄浣撶被涓湡姝g殑灞炴?br />
<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>
鍦↗SP欏甸潰寮曞叆Struts鏍囩搴撶殑鏃跺欐湁鎵涓嶅悓錛?/p>
struts1.3鐨勪負錛?/p>
<%@ taglib uri="
<%@ taglib uri="
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>鎴栬?lt;%@ taglib uri="
]]>
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<Resource
name="jdbc/test" ----------娉ㄦ剰錛歵est涓洪」鐩悕
auth="Container"----------璇ラ」涓轟笉鍙橀」
type="javax.sql.DataSource"----------璇ラ」涓轟笉鍙橀」
driverClassName="com.mysql.jdbc.Driver"----------鏁版嵁搴撻┍鍔ㄥ悕
url="jdbc:mysql://localhost:3306/haotian?autoReconnect=true"-------url
username="root"-----鐢ㄦ埛鍚?br />
password="root"------瀵嗙爜
maxActive="10" ------鏈澶ц繛鎺ユ暟
maxIdle="5" --------鏈澶х┖闂茶繛鎺ユ暟
maxWait="-1"/> ------鏈澶х瓑寰呮縐掓暟錛?1涓烘棤闄愮瓑寰?br />
</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涓洪厤緗枃浠朵腑鐨刵ame
//寰楀埌榪炴帴
try {
conn=ds.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
3.鎶奙ySQL5.0鐨勯┍鍔ㄥ寘鏀懼埌Tomcat鐨刲ib鐩綍涓嬶紝娉ㄦ剰錛氭槸Tomcat鐨刲ib錛岃屼笉鏄」鐩殑lib銆傦紙涓嶇煡閬撲負浠涔堜細榪欐牱錛屼箣鍓嶄笉鐢ㄨ繖縐嶈繛鎺ユ睜鐨勬椂鍊欐斁鍦ㄩ」鐩殑lib涓氨鍙互榪炴帴鎴愬姛錛屼絾鏄幇鍦ㄥ氨涓嶅彲浠ワ紝涓漢璁や負鍙兘鏄痗ontext.xml浣垮緱Tomcat鎵捐嚜韜玪ib涓殑椹卞姩鍖咃紝鑰屼笉鏄」鐩腑鐨勯┍鍔ㄥ寘錛?/p>
4.嫻嬭瘯錛?/p>
榪欓噷騫墮潪鏄湪榪炴帴綾婚噷闈㈠啓涓猰ain()灝卞彲浠ユ祴璇曟垚鍔熺殑錛屽鏋滆繖鏍蜂細鍑虹幇涓嬮潰鐨勯敊璇細
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)
鎵浠ワ紝鍙湁閫氳繃鍜屽墠鍙扮粨鍚堟墠鑳芥祴璇曡繛鎺ユ槸鍚︽垚鍔熴?/p>
鎬葷粨錛?/p>
context.xml蹇呴』鍦ㄩ」鐩殑WebRoot/META-INF錛孴omcat浼氳嚜鍔ㄦ壘榪欎釜鏂囦歡錛?/p>
鏁版嵁搴撻┍鍔ㄥ寘蹇呴』鏀懼湪Tomcat鐨刲ib鐩綍涓嬶紙鍙兘鏄疶omcat浼氭牴鎹甤ontext.xml鍦ㄨ嚜韜殑lib鐩綍涓嬫壘椹卞姩鍖咃級錛?/p>
涓嶅彲浠ョ洿鎺ュ湪榪炴帴綾諱腑鍐檓ain()嫻嬭瘯錛屽繀欏誨拰鍓嶅彴緇撳悎錛?/p>