Java ÀûÓÃÌ×½Ó×ÖSocketʵÏÖ¼òµ¥µÄ·þÎñÆ÷Óë¿Í»§¶ËͨÐÅ
ÎÒÃÇҪʵÏֵľßÌ幦ÄÜÊÇ£º
ÀûÓÃSocketÀàºÍServerSocketÀà±àдһ¸öC/S³ÌÐò£¬ÊµÏÖC/SͨÐÅ¡£
¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍTimeÃüÁ·þÎñÆ÷¶Ë½ÓÊܵ½¸Ã×Ö·û´®ºó½«·þÎñÆ÷¶Ëµ±Ç°Ê±¼ä·µ»Ø¸ø¿Í»§¶Ë£»¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍExitÃüÁ·þÎñÆ÷¶ËÏò¿Í»§¶Ë·µ»Ø“Bye”ºóÍ˳ö¡£
ÌâÄ¿±È½Ï¼òµ¥µÄ£¬ÎÒÃÇÖ±½ÓÀ´¿´´úÂë°É£º
Ê×ÏÈÊÇ·þÎñÆ÷¶ËµÄʵÏÖ£º
import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;
import java.text.DateFormat;
import java.util.Date;//ʱ¼ä
//import java.util.Calendar;
public class Server {
public static void main(String args[]){
try{
ServerSocket server = new ServerSocket(11111);//´´½¨·þÎñÆ÷Ì×½Ó×Ö
System.out.println("·þÎñÆ÷Æô¶¯Íê±Ï");
System.out.println("µÈ´ý¿Í»§¶ËÁ¬½Ó...");
Socket socket = server.accept();//µÈ´ý¿Í»§¶ËÁ¬½Ó
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));//»ñµÃ¿Í»§¶ËµÄÊäÈëÁ÷
//OutputStreamWriter out = new OutputStreamWriter(socket.getOutputStream());//»ñµÃ¿Í»§¶ËÊä³öÁ÷
PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);//»ñµÃ¿Í»§¶ËÊä³öÁ÷)
if(socket.isConnected()){
System.out.println("¿Í»§¶ËÃû³ÆΪ"+socket.getInetAddress().getHostAddress()+" Á¬½Ó³É¹¦£¡");
//out.write("Á¬½Ó³É¹¦\n");
out.println("Á¬½Ó³É¹¦");
}
while(true){
String str = reader.readLine();
if(str.equals("Time")){//¿Í»§¶ËÇëÇóʱ¼äÊý¾Ý
Date date = new Date();
// Calendar cal = Calendar.getInstance();
System.out.println("¿Í»§¶ËÇëÇóµ±Ç°Ê±¼ä");
DateFormat format = DateFormat.getDateInstance();
//out.write(format.format(date));//¸ñʽ»¯Êä³öʱ¼ä
out.println(format.format(date));
}
else if(str.equals("exit")){//Í˳ö
//out.write("bye");
out.println("bye");
System.out.println("Á¬½Ó¶Ï¿ª");
break;
}
else{
System.out.println("Êý¾Ý£º"+str);
}
}
}catch(IOException e){
e.pr
Ïà¹ØÎĵµ£º
ListµÄÓ÷¨
List°üÀ¨List½Ó¿ÚÒÔ¼°List½Ó¿ÚµÄËùÓÐʵÏÖÀà¡£ÒòΪList½Ó¿ÚʵÏÖÁËCollection½Ó¿Ú£¬ËùÒÔList½Ó¿ÚÓµÓÐCollection½Ó¿ÚÌṩµÄËùÓг£Ó÷½·¨£¬ÓÖÒòΪListÊÇÁбíÀàÐÍ£¬ËùÒÔList½Ó¿Ú»¹ÌṩÁËһЩÊʺÏÓÚ×ÔÉíµÄ³£Ó÷½·¨£¬Èç±í1Ëùʾ¡£
±í1 List½Ó¿Ú¶¨ÒåµÄ³£Ó÷½·¨¼°¹¦ÄÜ
´Ó±í1¿ÉÒÔ¿´³ö£¬List½Ó¿ÚÌṩµÄÊʺÏÓÚ×ÔÉíµÄ ......
ÔõôѧϰJava£¬ÕâÊǺܶàÐÂÊÖ¾³£»áÎÊÎÒµÄÎÊÌ⣬ÏÖÔÚÎÒ¼òµ¥ÃèÊöÏÂÒ»¸öJava³õѧÕßµ½¾ÍҵҪѧµ½µÄһЩ¶«Î÷£º
Ê×ÏÈÒªÃ÷°×JavaÌåϵÉè¼Æµ½µÃÈý¸ö·½Ã棺J2SE,J2EE,J2ME£¨KJAVA£©¡£J2SE£¬Java 2 Platform Standard
Edition£¬ÎÒÃǾ³£Ëµµ½µÄJDK£¬¾ÍÖ÷ÒªÖ¸µÄÕâ¸ö£¬ËüÊÇÈýÕߵĻù ......
ÀàµÄ°ü·ÃÎÊȨÏÞ£º¡¶Java±à³Ì˼Ïë¡·ÖÐÒ»¶Î»°µÄÀ§»ó
ÔÚ¡¶java±à³Ì˼ÏëµÚÈý°æ¡·£¨³Âê»Åô ÈÄÈô骵ÈÒ룩µÄµÚÎåÕÂÒþ²Ø¾ßÌåʵÏÖÖУ¬5.4½ÚµÄ×îºóÒ»¶Î»°ÊÇ£º
“ÕýÈçÇ°ÃæËùÌáµ½µÄ£¬Èç¹ûûÄÜΪÀà·ÃÎÊȨÏÞÖ¸¶¨Ò»¸ö·ÃÎÊÐÞÊηû£¬Ëü¾Í»áȱʡµÃµ½°ü·ÃÎÊȨÏÞ¡£ÕâÒâζןÃÀàµÄ¶ÔÏó¿ÉÒÔÓÉ°üÄÚÈκÎÆäËûÀàÀ´´´½¨£ ......
µÚ1Õ strutsÓëjava webÓ¦Óüò½é
1.1 java webÓ¦ÓøÅÊö
1.2 web×é¼þµÄÈýÖÖ¹ØÁª¹Øϵ
1.3 muv¸ÅÊö
1.4 struts¸ÅÊö
1.4.1 strutsʵÏÖmvcµÄ»úÖÆ
ÔÚstruts¿ò¼ÜÖУ¬Ä£ÐÍÓÉʵÏÖÒµÎñÂß¼µÄjavabean»òejb×é¼þ¹¹³É£¬¿ØÖÆÆ÷ÓÉ
ActionServletºÍActionÀàʵÏÖ£¬ÊÓͼÓÉÒ»×éjspÎļþ¹¹³É¡£
1.ÊÓͼ
ÊÓͼ¾ÍÊÇjspÎļþ¡£ÔÚÕâЩjspÎļþ ......