1.1、示例
/*上傳圖片*/import java.net.*;import java.io.*;import java.util.*;import java.text.*;/*客戶端1.建立客戶端服務2.讀取客戶端已經有數據,,將文件名發送給服務端3.通過Scoket,輸出流將數據發送給服務端4.接收服務端返回信息5.關流Socket和流資源*/class UploadClient1{ public static void main(String[] args) throws Exception { //建立片客戶端服務 Socket s=new Socket("localhost",10009); //客戶端資源 File file=new File("d://1.jpg"); //獲取文件名 String filename=file.getName(); //獲取打印流,并將文件名發送到服務端,true表示自動刷新 PRintWriter pw=new PrintWriter(s.getOutputStream(),true); pw.println(filename); //字節緩沖流讀取文件 BufferedInputStream bis=new BufferedInputStream(new FileInputStream(file)); //字節緩沖輸出流 BufferedOutputStream bosOut=new BufferedOutputStream(s.getOutputStream()); int len=0; while((len=bis.read())!=-1) { bosOut.write(len); bosOut.flush(); } //增加結束標記 s.shutdownOutput(); //字節緩沖輸入流,用于接收服務端發回的數據 BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream())); String rep=br.readLine(); System.out.println(rep); bis.close(); s.close(); }}/*服務端1.建立服務端服務,并指定端口2.接收客戶端發送的文件名,讀取客戶端發送的數據3.通過Scoket,輸出流將數據寫在服務端文件4.發送返回信息5.關流Socket和流資源*/class UploadServer1{ public static void main(String[] args) throws Exception { //建立服務端服務,指定端口 ServerSocket ss=new ServerSocket(10009); //建立客戶端Socket對象 Socket s=ss.accept(); //字節緩沖輸入流,用于接收服務端發回的數據 BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream())); String filename=br.readLine(); System.out.println(filename); //文件讀取流 BufferedInputStream bisIn=new BufferedInputStream(s.getInputStream()); //建立服務端文件 File file=new File("f://",filename); if(file.exists()) { //如果文件存在就重命名 SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd HHmmss"); Date date=new Date(); String time=sdf.format(date); //只獲取文件名的部分 String name=filename.substring(0,filename.indexOf(".")); String prefix=name+time; //擴展名 String suffix=filename.substring(filename.indexOf(".")); filename=prefix+suffix; //重新指定文件 file=new File("f://",filename); } FileOutputStream fos=new FileOutputStream(file); byte[] bufw=new byte[1024]; int len=0; while((len=bisIn.read(bufw))!=-1) { fos.write(bufw,0,len); } PrintWriter pw=new PrintWriter(s.getOutputStream(),true); pw.println("上傳成功"); fos.close(); s.close(); ss.close(); }}
2.1、示例
客戶端:
package com.pb.demo2;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;import java.io.OutputStream;import java.io.PrintWriter;import java.net.Socket;/*客戶端*/class FileUploadClient { public static void main(String[] args) throws Exception { //建立片客戶 端服務 Socket s=new Socket("localhost",10010); //獲取文件 File file=new File("d://gm.mp3"); //獲取流把文件名發送出去 String filename=file.getName(); System.out.println(filename); PrintWriter pw=new PrintWriter(s.getOutputStream(),true); //發送文件名 pw.println(filename); //輸出流 OutputStream os=s.getOutputStream(); //文件讀取流 FileInputStream fis=new FileInputStream(file); int len=0; byte [] buf=new byte[1024]; //開始讀取,并把文件通過網絡流socket發送到服務端 while((len=fis.read(buf))!=-1) { os.write(buf,0,len); } //發送發閉,發送結束標記 s.shutdownOutput(); //接收服務器返回的信息 InputStream is=s.getInputStream(); byte [] bfw=new byte[1024]; int repLen=is.read(bfw); String rep=new String(bfw,0,repLen); System.out.println(rep); fis.close(); s.close(); }}
服務端
package com.pb.demo2;import java.net.ServerSocket;import java.net.Socket;/*服務端*/class FileUploadServer{ public static void main(String[] args) throws Exception { //建立服務端服務 ServerSocket ss=new ServerSocket(10010); //建立循環監聽,一直運行 while(true) { Socket s=ss.accept(); //每個客戶端 都一個單獨的線程 new Thread(new FileServerThread(s)).start(); } }}
線程
package com.pb.demo2;import java.io.BufferedReader;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.net.Socket;/*服務端線程類*/class FileServerThread implements Runnable{ //Socket做為參數 private Socket s; public FileServerThread(Socket s) { this.s=s; } //多線程方法 public void run() { //定一個計數器用來給文件重命名 int count=1; //獲取ip String ip=s.getInetAddress().getHostAddress(); System.out.println(ip+".................connected"); try { //讀取流 BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream())); //讀取文件名 String filename=br.readLine(); System.out.println(filename); File file=new File("f://",filename); //判斷文件是否存在 while(file.exists()) { //截取文件名前綴與后綴 String prefix=null; String suffix=null; String name=filename.substring(0,filename.indexOf(".")); //判斷文件名是否有( if(name.contains("(")) { prefix=filename.substring(0,filename.indexOf("(")); }else{ prefix=name; } prefix=prefix+"("+(count++)+")"; suffix=filename.substring(filename.lastIndexOf(".")); //文件名重命名 filename=prefix+suffix; file=new File("f://",filename); System.out.println(filename); } //讀取文件 InputStream isr=s.getInputStream(); //輸出流 FileOutputStream fos=new FileOutputStream(file); int len=0; byte [] bufw = new byte[1024]; while((len=isr.read(bufw))!=-1) { fos.write(bufw,0,len); } //發送信息到客戶端 OutputStream os=s.getOutputStream(); os.write("上傳成功".getBytes()); fos.close(); s.close(); } catch (Exception e) { throw new RuntimeException("上傳失敗!"); } }}
3.1、示例
/*客戶端 鍵盤輸入用戶名服務端對這個用戶名進行校驗如果該用戶名存在,在服務端顯示XXX,已經登錄并在客戶端顯示XXX,歡迎光臨如果該用戶不存在,在服務端顯示XXX,嘗試登錄并在客戶顯示XXX,該用戶不存在最多登錄三次*//*客戶端*/import java.net.*;import java.io.*;class LoginClient{ public static void main(String[] args) throws Exception { //建立客戶端服務 Socket s=new Socket("localhost",10010); //接收鍵盤錄入 BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); //打印流,向服務端發送信息 PrintWriter pw=new PrintWriter(s.getOutputStream(),true); //接收服務端返回的信息 BufferedReader brIn=new BufferedReader(new InputStreamReader(s.getInputStream())); for(int x=0;x<3;x++) { //接收鍵盤輸入 String line=br.readLine(); if(line==null) break; pw.println(line); //返回信息 String info=brIn.readLine(); System.out.println(info); //比較是否登錄成功 if(info.contains("歡迎")) break; } br.close(); s.close(); }}/*服務端*/class LoginServer{ public static void main(String[] args) throws Exception { //建立服務端服務 ServerSocket ss=new ServerSocket(10010); while(true) { //建立監聽 Socket s=ss.accept(); new Thread(new LoginThread(s)).start(); } }}/*服務端登錄線程*/class LoginThread implements Runnable{ private Socket s; public LoginThread(Socket s) { this.s=s; } public void run() { //IP String ip=s.getInetAddress().getHostAddress(); System.out.println(ip+"......connected"); try { BufferedReader brIn=null; BufferedReader br=null; PrintWriter pw=null; //只校驗3次 for(int x=0;x<3;x++) { //讀取客戶端信息 brIn=new BufferedReader(new InputStreamReader(s.getInputStream())); //用戶名 String username=brIn.readLine(); if(username==null) break; //讀取文件判斷 br=new BufferedReader(new InputStreamReader(new FileInputStream("f://user.txt"))); //向客戶端發送信息 pw=new PrintWriter(s.getOutputStream(),true); //文件內容 String line=null; boolean flag=false; while((line=br.readLine())!=null) { if(line.equals(username)) { //找到,結束,標記為true flag=true; break; } } //判斷 if(flag) { System.out.println(username+"已經登錄!"); pw.println(username+",歡迎光臨!"); } else { System.out.println(username+"嘗試登錄!"); pw.println(username+",該用戶不存在!"); } } //關閉 br.close(); s.close(); } catch (Exception e) { throw new RuntimeException("登錄失敗"); } }}/*user.txtzhangsanlisiwangwuqianqi*/
4.1、示例
/*建立服務端,自定義服務端通過瀏覽器,訪問服務端*/import java.net.*;import java.io.*;class ServerDemo{ public static void main(String[] args) throws Exception { //建立服務端 ServerSocket ss=new ServerSocket(11000); //獲取 Socket s=ss.accept(); String ip=s.getInetAddress().getHostAddress(); System.out.println(ip+"........connected"); //向瀏覽器客戶端發送數據 PrintWriter out=new PrintWriter(s.getOutputStream(),true); out.println("<font color='red' size='10'>"+ip+"客戶</font>"); s.close(); ss.close(); }}
5.1、示例
6.1、示例
package com.pb.tcp;import java.net.*;import java.io.*;class MyIE{ public static void main(String[] args) throws Exception { Socket s=new Socket("localhost",8080); PrintWriter out=new PrintWriter(s.getOutputStream(),true); out.println("GET /examples/index.jsp HTTP/1.1"); out.println("Accept: text/html, application/xhtml+xml, */*"); out.println("Accept-Language: zh-CN"); out.println("Host: localhost:11000"); out.println("Connection: Keep-Alive"); out.println(); out.println(); System.out.println("=============="); InputStream is=s.getInputStream(); byte[] buf=new byte[1024]; int len=0; while((len=is.read(buf))!=-1){ System.out.println(new String(buf,0,len)); } s.close(); }}/*Http:請求頭消息頭GET / HTTP/1.1 瀏覽向服務器發送一個get請求,使用的是http:1.1協議Accept: text/html, application/xhtml+xml, 支持的數據類型,可以有更多Accept-Language: zh-CN ,瀏覽器支持的語言是簡體中文User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) 用戶信息Accept-Encoding: gzip, deflate 支持的編碼,壓縮格式,Host: 127.0.0.1:11000 訪問的主機地址和端口Connection: Keep-Alive 連接,保持連接*/
==============HTTP/1.1 404 Not FoundServer: Apache-Coyote/1.1Content-Type: text/html;charset=utf-8Content-Language: enContent-Length: 1030Date: Sun, 18 Oct 2015 13:47:51 GMT<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.26 - Error report</title><style type="text/CSS">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 404 - /examples/index.jsp</h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u>/examples/index.jsp</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><hr class="line"><h3>Apache Tomcat/8.0.26</h3></body></html>
示例:圖形化界面
package com.pb.demo2;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import java.net.*;import java.io.*;//http://localhost:8080/myweb/my.htmlpublic class MyFrame { private Frame f; private Button b; private TextField tf; private TextArea ta; public MyFrame(){ init(); } public void init(){ f=new Frame("我的窗體"); f.setBounds(300, 100, 600, 500); f.setLayout(new FlowLayout()); tf=new TextField(50); b=new Button("GO"); ta=new TextArea(20,50); f.add(tf); f.add(b); f.add(ta); myEvent(); f.setVisible(true); } public void myEvent(){ //按鍵添加監聽器,事件輸入完成,點按鍵執行 b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //調用顯示 show(); } } ); //文本框添加事件監聽,輸入完成,敲回車執行 tf.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if(e.getKeyCode()==KeyEvent.VK_ENTER) { //調用 show(); } } } ); } private void show(){ //獲取文本框中輸入的內容 String url=tf.getText(); //獲取包含//的下標+2 int index1=url.indexOf("http://")+2; //獲取/的下標 int index2=url.indexOf("/",index1); //獲取//----/之間的內容 String str=url.substring(index1, index2); //按:分割192.168.1.254:8080 String [] arr=str.split(":"); String host=arr[0]; int port=Integer.parseInt(arr[1]); //獲取/后面的路徑 String path=url.substring(index2); //添加到文本域中 ta.append(host+"..."+port+"..."+path); try { showWeb(host,port,path); } catch (Exception e) { e.printStackTrace(); } } private void showWeb(String host,int port,String path) throws Exception{ //瀏覽器 Socket s=new Socket(host,port); //打印流,true,自動刷新 PrintWriter out=new PrintWriter(s.getOutputStream(),true); out.println("GET "+path+" HTTP/1.1"); out.println("Accept: */*"); out.println("Accept-Language: zh-CN"); out.println("Host: 127.0.0.1:11000"); out.println("Connection: Keep-Alive"); out.println(); out.println(); InputStream is=s.getInputStream(); byte [] buf=new byte[1024]; int len=0; while((len=is.read(buf))!=-1){ ta.append(new String(buf,0,len)); } s.close(); } public static void main(String[] args) { new MyFrame(); }}/*Http:請求頭消息頭GET / HTTP/1.1 瀏覽向服務器發送一個get請求,使用的是http:1.1協議Accept: text/html, application/xhtml+xml, 支持的數據類型,可以有更多Accept-Language: zh-CN ,瀏覽器支持的語言是簡體中文User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) 用戶信息Accept-Encoding: gzip, deflate 支持的編碼,壓縮格式,Host: 127.0.0.1:11000 訪問的主機地址和端口Connection: Keep-Alive 連接,保持連接*/
7.1、方法
類 URL
代表一個統一資源定位符,它是指向互聯網“資源”的指針。資源可以是簡單的文件或目錄,也可以是對更為復雜的對象的引用,例如對數據庫或搜索引擎的查詢。有關 URL 的類型和格式的更多信息,可從以下位置找到:
http://www.socs.uts.edu.au/MosaicDocs-old/url-primer.html
通常,URL 可分成幾個部分。上面的 URL 示例指示使用的協議為 http
(超文本傳輸協議)并且該信息駐留在一臺名為 www.socs.uts.edu.au
的主機上。主機上的信息名稱為 /MosaicDocs-old/url-primer.html
。主機上此名稱的準確含義取決于協議和主機。該信息一般存儲在文件中,但可以隨時生成。該 URL 的這一部分稱為路徑 部分。
URL 可選擇指定一個“端口”,它是用于建立到遠程主機 TCP 連接的端口號。如果未指定該端口號,則使用協議默認的端口。例如,http
協議的默認端口為 80
。還可以指定一個備用端口,
構造方法摘要 | |
---|---|
URL(String spec) 根據 String 表示形式創建 URL 對象。 | |
URL(String protocol, String host, int port, String file) 根據指定 protocol 、host 、port 號和 file 創建 URL 對象。 | |
URL(String protocol, String host, int port, String file, URLStreamHandler handler) 根據指定的 protocol 、host 、port 號、file 和 handler 創建 URL 對象。 | |
URL(String protocol, String host, String file) 根據指定的 protocol 名稱、host 名稱和 file 名稱創建 URL。 | |
URL(URL context, String spec) 通過在指定的上下文中對給定的 spec 進行解析創建 URL。 | |
URL(URL context, String spec, URLStreamHandler handler) 通過在指定的上下文中用指定的處理程序對給定的 spec 進行解析來創建 URL。 |
方法摘要 | |
---|---|
boolean | equals(Object obj) 比較此 URL 是否等于另一個對象。 |
String | getAuthority() 獲取此 URL 的授權部分。 |
Object | getContent() 獲取此 URL 的內容。 |
Object | getContent(Class[] classes) 獲取此 URL 的內容。 |
int | getDefaultPort() 獲取與此 URL 關聯協議的默認端口號。 |
String | getFile() 獲取此 URL 的文件名。 |
String | getHost() 獲取此 URL 的主機名(如果適用)。 |
String | getPath() 獲取此 URL 的路徑部分。 |
int | getPort() 獲取此 URL 的端口號。 |
String | getProtocol() 獲取此 URL 的協議名稱。 |
String | getQuery() 獲取此 URL 的查詢部分。 |
String | getRef() 獲取此 URL 的錨點(也稱為“引用”)。 |
String | getUserInfo() 獲取此 URL 的 userInfo 部分。 |
int | hashCode() 創建一個適合哈希表索引的整數。 |
URLConnection | openConnection() 返回一個 URLConnection 對象,它表示到 URL 所引用的遠程對象的連接。 |
URLConnection | openConnection(Proxy proxy) 與 openConnection() 類似,所不同是連接通過指定的代理建立;不支持代理方式的協議處理程序將忽略該代理參數并建立正常的連接。 |
InputStream | openStream() 打開到此 URL 的連接并返回一個用于從該連接讀入的 InputStream 。 |
boolean | sameFile(URL other) 比較兩個 URL,不包括片段部分。 |
protected void | set(String protocol, String host, int port, String file, String ref) 設置 URL 的字段。 |
protected void | set(String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) 設置 URL 的指定的 8 個字段。 |
static void | setURLStreamHandlerFactory(URLStreamHandlerFactory fac) 設置應用程序的 URLStreamHandlerFactory 。 |
String | toExternalForm() 構造此 URL 的字符串表示形式。 |
String | toString() 構造此 URL 的字符串表示形式。 |
URI | toURI() 返回與此 URL 等效的 URI 。 |
7.2、示例
URL url=new URL("http://127.0.0.1/myweb/demo.html?name=wangwu&age=89"); System.out.println("Protocol:"+url.getProtocol()); System.out.println("Host:"+url.getHost()); System.out.println("Port :"+url.getPort()); System.out.println("Path :"+url.getPath()); System.out.println("File :"+url.getFile()); System.out.println("Query :"+url.getQuery());
/* String getAuthority() 獲取此 URL 的授權部分。 Object getContent() 獲取此 URL 的內容。 Object getContent(Class[] classes) 獲取此 URL 的內容。 int getDefaultPort() 獲取與此 URL 關聯協議的默認端口號。 String getFile() 獲取此 URL 的文件名。 String getHost() 獲取此 URL 的主機名(如果適用)。 String getPath() 獲取此 URL 的路徑部分。 int getPort() 獲取此 URL 的端口號。 String getProtocol() 獲取此 URL 的協議名稱。 String getQuery() 獲取此 URL 的查詢部分。 String getRef() 獲取此 URL 的錨點(也稱為“引用”)。 String getUserInfo() 獲取此 URL 的 userInfo 部分。 */
URL url=new URL("http://127.0.0.1:8080/myweb/my.html?name=java&age=30"); System.out.println("getAuthority:"+url.getAuthority()); System.out.println("getContent:"+url.getContent()); System.out.println("getDefaultPort:"+url.getDefaultPort()); System.out.println("getFile:"+url.getFile()); System.out.println("getHost:"+url.getHost()); System.out.println("getPath:"+url.getPath()); System.out.println("getPort:"+url.getPort()); System.out.println("getProtocol:"+url.getProtocol()); System.out.println("getQuery:"+url.getQuery()); System.out.println("getRef:"+url.getRef()); System.out.println("getUserInfo:"+url.getUserInfo());
getAuthority:127.0.0.1:8080getContent:sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@70dea4egetDefaultPort:80getFile:/myweb/my.html?name=java&age=30getHost:127.0.0.1getPath:/myweb/my.htmlgetPort:8080getProtocol:httpgetQuery:name=java&age=30getRef:nullgetUserInfo:null
示例2、URLConnection沒有頭文件
package com.pb.demo2;import java.io.*;import java.net.*;/* * URLConnection 封裝了Socket */public class URLConnectionDemo {//127.0.0.1:8080/myweb/my.html?name=java&age=30 public static void main(String[] args) throws IOException { URL url=new URL("http://127.0.0.1:8080/myweb/my.html?name=java&age=30"); //返回一個URL遠程連接對象 URLConnection conn=url.openConnection(); //輸出連接對象 System.out.println(conn); InputStream is=conn.getInputStream(); int len=0; byte[] buf=new byte[1024]; while((len=is.read(buf))!=-1){ System.out.println(new String(buf,0,len)); } }}
sun.net.www.protocol.http.HttpURLConnection:http://127.0.0.1:8080/myweb/my.html?name=java&age=30<html><head> <title>我的頁面</title></head><body> <h1>這是個標題</h1></body></html>
示例3:改變第六中的示例
package com.pb.demo2;import java.awt.Button;import java.awt.*;import java.awt.event.*;import java.io.*;import java.net.*;//http://localhost:8080/myweb/my.htmlpublic class MyFrame2 { private Frame f; private Button b; private TextField tf; private TextArea ta; public MyFrame2(){ init(); } public void init(){ f=new Frame("我的窗體"); f.setBounds(300, 100, 600, 500); f.setLayout(new FlowLayout()); tf=new TextField(30); b=new Button("GO"); ta=new TextArea(20,50); f.add(tf); f.add(b); f.add(ta); f.setVisible(true); myEvent(); } public void myEvent(){ //窗體監聽器, f.addWindowListener(new WindowAdapter(){ //關閉事件 public void windowClosing(WindowEvent e) { System.out.println("fsdfdsfds"); System.exit(0); } }); //按鍵添加監聽器,事件輸入完成,點按鍵執行 b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //調用顯示 try { show(); } catch (IOException e1) { e1.printStackTrace(); } } } ); //文本框添加事件監聽,輸入完成,敲回車執行 tf.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if(e.getKeyCode()==KeyEvent.VK_ENTER) { //調用 try { show(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } } ); } public void show() throws UnknownHostException, IOException{ ta.setText(""); //獲取文本框中輸入的內容 String urlPath=tf.getText(); URL url=new URL(urlPath); //和目標url建立連接 URLConnection conn=url.openConnection(); //添加到文本域中 //瀏覽器接收信息封裝了Socket可以使用Socket中的流對象 InputStream is=conn.getInputStream(); byte [] buf=new byte[1024]; int len=0; while((len=is.read(buf))!=-1){ ta.setText(new String(buf,0,len)); } } public static void main(String[] args) { new MyFrame2(); }} /* Http:請求頭消息頭 GET / HTTP/1.1 瀏覽向服務器發送一個get請求,使用的是http:1.1協議 Accept: text/html, application/xhtml+xml, 支持的數據類型,可以有更多 Accept-Language: zh-CN ,瀏覽器支持的語言是簡體中文 User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5. 0) 用戶信息 Accept-Encoding: gzip, deflate 支持的編碼,壓縮格式, Host: 127.0.0.1:11000 訪問的主機地址和端口 Connection: Keep-Alive 連接,保持連接 */
8.1、概述
127.0.0.1與localhost映射關系在本機
域名與IP可以在hosts中配置映射
C:/Windows/System32/drivers/etc/hosts文件中配置
新聞熱點
疑難解答