为什么我的浏览器在Firefox中使用MIME时不显示我的HTML文件

时间:2015-02-07 06:49:05

标签: java html firefox mime

我正在构建一个网络服务器......这是我发送回浏览器的流:

File f = new File(".");
                    File f2 = new File(f.getCanonicalPath() + "/cat.html");
                    InputStream file = new FileInputStream(f2);  

                    try {

                        String mode;
                        String mode2;
                        String mode3;
                        String mode4;
                        String mode5;
                        mode = in.readLine();
                        System.out.println(mode);
                        mode2 = in.readLine();
                        System.out.println(mode2);
                        mode3 = in.readLine();
                        System.out.println(mode3);
                        mode4 = in.readLine();
                        System.out.println(mode4);
                        mode5 = in.readLine();
                        System.out.println(mode5);
                        out.println("HTTP/1.1 200 OK \r\n " + 
                                "Content-Type: text/html shtml;    \r\n" +
                                "Content-Length: 1000 \r\n" +
                                "Date: 01/06/2015 \r\n" +
                                "Server: FileServer 1.0 \r\n\r\n");
                    sendFile(file, out);

 private static void sendFile(InputStream file, OutputStream out)
        {
            try {
                byte[] buffer = new byte[1000];
                while (file.available()>0) 
                    out.write(buffer, 0, file.read(buffer));
            } catch (IOException e) { System.err.println(e); }
        }

它在IE中正确显示但在Firefox或Google Chrome中没有显示...我做错了什么?我收到了RAW HTML,但没有格式化的HTML

0 个答案:

没有答案