当前页面: 开发资料首页 → 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类