繁体   English   中英

Java(JSP)无法在system.out.println中打印出“ 0x0a”或“ \\ n”新行

[英]Java (JSP) not printing out the “0x0a” or “\n” new line in system.out.println

好的,首先,我正在开发OCR。 Tesseract在txt文件中向我返回了一串字符串。 我应该阅读文本文件并将其显示在jsp上。

当前,在Windows记事本上查看时,我的文本是这样的:

Hello World!This is a sample text.

在记事本++上查看:

Hello World!
This is a sample text.

当我通过读取文件在jsp中运行代码(如下所示)时,它的显示方式类似于Windows记事本显示的方式,而不是Sublime Text Editor。 我希望文本能换行,而不是合并在一起。

<%
            String file_name=(String)request.getParameter("file_name");
            String file_name_given=(String)request.getParameter("file_name_given");
            //creating the out put file after upload and reading
            create_file obj_create_file=new create_file();
            obj_create_file.create_output_file(file_name);
            //read the created out put file
            read_file obj_read_file=new read_file();
            String read=obj_read_file.read_file(file_name);
            System.out.println(read);
%>

如何修改显示断线而不是连续字符串的代码? 我怀疑它与ASCII字符“ 0x0a”有关。

从JSP发送到浏览器的内容通常被解释为HTML。 在HTML中,换行符只是空白。 他们不会给您换行。

要在HTML中换行,您需要输出<br><p>或类似的东西。 如果这样做对您没有帮助,我建议您查找并阅读HTML教程或教科书。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM