我在网页中应用了语法荧光笔,但是当我最小化窗口或在其他屏幕上检查它时,文本消失了。

我已经尝试了很多,但是仍然出现了问题。我使用了语法荧光笔形式rawgit。

还有其他选择吗?

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <link rel="stylesheet" href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css"/>
        <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
    </head>
    <body>
        <pre class="prettyprint"><code>
package com.up;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;

@Path("/files")
public class FileUploadService {

    @POST
    @Path("/upload")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response uploadFile(
            @FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail
    ) {
        String fileLocation = "F://" + fileDetail.getFileName();
        try {
            FileOutputStream out = new FileOutputStream(new File(fileLocation));
            int read = 0;
            byte[] bytes = new byte[1024];
            out = new FileOutputStream(new File(fileLocation));
            while ((read = uploadedInputStream.read(bytes)) != -1) {
                out.write(bytes, 0, read);
            }
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        String output = "File successfully uploaded to : " + fileLocation;
        return Response.status(200).entity(output).build();
    }

} </code></pre>
    </body>
</html>

最佳答案

将溢出滚动添加到您的prettyprint

.prettyprint {
overflow:scroll;
}

10-08 16:58