java中的system.out.println()和JSP中out.println()區別,system.out.println

來源:互聯網
上載者:User

java中的system.out.println()和JSP中out.println()區別,system.out.println

out.println()輸出到用戶端。    在out.println()中,out是response的執行個體,是以response為對象進行流輸出的,即將內容輸出到用戶端。如果在JSP頁面中使用System.out.println(),在用戶端只會輸出一個空格。System.out.println()列印在控制台當中。    System.out.println()用的是標準輸出資料流,這個是輸出在控制台上的,而JSP不是控制台程式。不管是在JSP還是在JAVA程式中,System.out.println()都是列印在控制台上。 如果想列印在頁面,簡單點的方法是:out.print( "要列印的內容" );     其實在正規的網站建設中,是從來不用out.println()的,都是直接使用標籤。例:伺服器平台:tomcat。用戶端:firefox瀏覽器。來源程式://test.jsp檔案<%@page contentType="text/html;charset=gb2312"%><html><body> <%@ page import = "java.util.Date"%><%out.println("This is printed by out.println.");System.out.println("This is printed by System.out.println.");System.out.println("This is printed by System.out.println.");System.out.println("This is printed by System.out.println.");out.println("This is printed by out.println.");%> </body></html>用戶端(瀏覽器)中的結果:從中可看出兩個out.println()輸出的內容間有一個空格(儘管來源程式調用了3次System.out.println)。控制台中的結果:從可看到調用3次System.out.println()的內容(其餘的是伺服器資訊 )。

為何jsp中不可以用Systemoutprintln()而要用outprintln()

<%.........%>裡面可以用System.out.println()啊~~~
你是不是搞混了???
在<%.........%>裡就是java片段啊,
在jsp裡
System.out.println()和out.println()的區別是
前者 是在控制台列印,而後者是輸出到用戶端,也就是頁面
 
java中systemoutprint與systemoutprintln的不同

system.out.println=system.out.print+system.out.print(“\n”)
就是加了一換行
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.