newLine方法的用法

来源:互联网 发布:小升初网络信息平台 编辑:程序博客网 时间:2024/04/28 15:42

newLine()方法可用于输出一个换行字符"/n",以下为简单例子

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" %>
<html>
<head>
<title>newLine</title>
</head>
<body>
<pre>
<%= "Hello World!"%><% out.newLine(); %><%= "Hello World!" %>
</pre>
</body>
</html>

其中,利用<pre></pre>这个标签可以将其包起来的文字排版、格式,原封不动的呈现出来。算是相当好用的标签之一。也就是说你输入的东西被原封不动的输出,包括你输入的空格之类的,不用 和<BR>等来表示空格或者回车了

输出结果:

Hello World!

Hello World!