1 import java.io.IOException;
 2 import java.io.PrintWriter;
 3 import java.net.ServerSocket;
 4 import java.net.Socket;
 5 
 6 //可以通过你的浏览器的客户端来访问
 7 //对于Tomcat理解方式:就是一种用纯java语言编写的面向服务器的软件。
 8 public class ServerDome {
 9     public static void main(String[] args) throws IOException {
10         while(true){
11             //建立服务器对象,并指定监听的端口号
12         ServerSocket ss=new ServerSocket(8080);
13         
14         //等待客户端发送通信
15         Socket s=ss.accept();
16         System.out.println(s.getInetAddress().getHostAddress());//留下你的ip
17         PrintWriter out=new PrintWriter(s.getOutputStream(),true);//就是在你的客户端上打印
18         
19         //行内样式
20         out.println("<div style='padding:5px 10px 20px 30px;background-color:red;width:300px;height:300px;float;left>" +
21                 "baoshengbo" +
22                 "</div> ");
23 
24         out.println("<div style='padding:5px 10px 20px 30px;background-color:green;width:300px;height:300px;float;left>" +
25                 "baoshengbo" +
26                 "</div>");
27         
28         
29         out.println("<font color='red' size='7'>开始做网页了</font>");
30         out.println("<a href='http://www.baidu.com/'>click</a>");
31         s.close();//关闭
32         ss.close();
33         }
34     }
35 }

 

相关文章:

  • 2021-09-09
  • 2022-01-10
  • 2022-12-23
  • 2022-01-05
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-06-30
  • 2021-12-31
  • 2021-10-03
相关资源
相似解决方案