站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2SE 专题如何通过url得到网页的编码格式?

如何通过url得到网页的编码格式?

摘要: 如何通过url得到网页的编码格式?


不下载网页,如何通过url得到网页的编码格式?


关注一下


可以解析header


建议看一下java.net.URLConnection类


对,从head里面取出需要的


public class Charset {
public static void main(String[] args) throws IOException {
URL url = new URL("http://www.qq.com/");
URLConnection conn = url.openConnection();
System.out.println(conn.getContentType());
}
}


public class Charset {
public static void main(String[] args) throws IOException {
URL url = new URL("http://www.qq.com/");
URLConnection conn = url.openConnection();
System.out.println(conn.getContentType());
}
}



何必这么麻烦,直接在jsp页面里

<%=request.getheader("accept-encoding")%>


head数据
url类


↑返回目录
前一篇: 关于java模拟IE下载的问题
后一篇: 如何给JTextFiled固定宽度?