?? read_rss.jsp
字號(hào):
<%@ page contentType="text/xml; charset=UTF-8"%>
<%@ page language="java"%>
<%@ page import="org.apache.commons.httpclient.*,org.apache.commons.httpclient.methods.GetMethod"%>
<%
out.clear(); //清空當(dāng)前的輸出內(nèi)容(空格和換行符)
String url = request.getParameter("url"); //獲取URL地址
HttpClient client = new HttpClient(); //創(chuàng)建Http客戶端對(duì)象
GetMethod method = new GetMethod(url); //創(chuàng)建一個(gè)Get請(qǐng)求方法
try {
client.executeMethod(method); //執(zhí)行Get請(qǐng)求方法
byte[] responseBody = method.getResponseBody(); //獲取響應(yīng)結(jié)果
out.print(new String(responseBody, "UTF-8")); //將獲取的結(jié)果以UTF-8編碼輸出到響應(yīng)體
} catch (Exception e) {
} finally {
method.releaseConnection(); //釋放Http連接
}
%>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -