2013年7月30日星期二

out.print and out.write Method

<%@ page language="java" import="java.util.*"  %> 
<%@ page pageEncoding="UTF-8" isELIgnored="false" %>
<%@ page import="java.util.Date" %>

<html>
<head>
<title> </title>
</head>
<body>
<h1>?????</h1>
<%=new Date() %>
</body>
</html>

posttranslational generated servlet, corresponding to the body , there is the following code :

out.write("<h1>?????</h1>\n"); 
out.print(
new Date());

(java in ) with this method : print (Object), without this method : write (Object)
but there is this method : write (String)
Find javaAPI, you will find .
Summary :
out.print () method, you can output a java object ;
out.write () method , can only enter a string.

没有评论:

发表评论