第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

關(guān)于在jsp中String = null 和String = “”的使用問(wèn)題!

關(guān)于在jsp中String = null 和String = “”的使用問(wèn)題!

月亮島Superman 2017-08-04 13:32:18
<%@ page language="java" contentType="text/html; charset=gbk"?? ?pageEncoding="gbk"%><%@ page import="java.sql.*"%><%!String str = null;?? ?private void tree(Connection conn, int id, int level) {?? ??? ?Statement stmt = null;?? ??? ?ResultSet rs = null;?? ??? ?String preStr = "";?? ??? ?for (int i = 0; i < level; i++) {?? ??? ??? ?preStr += "----";?? ??? ?}?? ??? ?try {?? ??? ??? ?stmt = conn.createStatement();?? ??? ??? ?String sql = "select * from article where pid = " + id;?? ??? ??? ?rs = stmt.executeQuery(sql);?? ??? ??? ?while (rs.next()) {?? ??? ??? ??? ?str += "<tr><td>" + rs.getInt("id") + "</td><td>" + preStr + rs.getString("title") + "</td></tr>";?? ??? ??? ??? ?if (rs.getInt("isleaf") != 0) {?? ??? ??? ??? ??? ?tree(conn, rs.getInt("id"), level + 1);?? ??? ??? ??? ?}?? ??? ??? ?}?? ??? ?} catch (Exception e) {?? ??? ??? ?e.printStackTrace();?? ??? ?} finally {?? ??? ??? ?try {?? ??? ??? ??? ?if (rs != null) {?? ??? ??? ??? ??? ?rs.close();?? ??? ??? ??? ??? ?rs = null;?? ??? ??? ??? ?}?? ??? ??? ??? ?if (stmt != null) {?? ??? ??? ??? ??? ?stmt.close();?? ??? ??? ??? ??? ?stmt = null;?? ??? ??? ??? ?}?? ??? ??? ?} catch (SQLException e) {?? ??? ??? ??? ?e.printStackTrace();?? ??? ??? ?}?? ??? ?}?? ?}%><%?? ?Class.forName("com.mysql.jdbc.Driver");?? ?//System.out.println("1");?? ?String url = "jdbc:mysql://localhost/test?user=root&password=root";?? ?Connection conn = DriverManager.getConnection(url);?? ?Statement stmt = conn.createStatement();?? ?ResultSet rs = stmt.executeQuery("select * from article where pid = 0");?? ?//System.out.println("2");?? ?while (rs.next()) {?? ??? ?str += "<tr><td>" + rs.getInt("id") + "</td><td>" + rs.getString("title") + "</td></tr>";?? ??? ?System.out.println(str);?? ??? ?if (rs.getInt("isleaf") != 0) {?? ??? ??? ?tree(conn, rs.getInt("id"), 1);?? ??? ?}?? ?}?? ?rs.close();?? ?stmt.close();?? ?conn.close();%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk"><title>Insert title here</title></head><body>?? ?<table border="1"><%=str%></table></body></html>問(wèn)題: String str = null;? 如果我這樣使用 瀏覽器中顯示結(jié)果為??? 在表格上方會(huì)有一個(gè)null? 但是我用String str = “”就不會(huì)出現(xiàn)這種問(wèn)題,這是為什么呢?
查看完整描述

2 回答

?
拖鞋_

TA貢獻(xiàn)453條經(jīng)驗(yàn) 獲得超223個(gè)贊

JSP 不要學(xué)了? 現(xiàn)在都是前端靜態(tài)化? 為了? 放入CDN?? JSP? 什么的都不支持的

查看完整回答
1 反對(duì) 回復(fù) 2017-08-04
?
qq_逆流河_0

TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個(gè)贊

null標(biāo)示你這個(gè)String對(duì)象不指向具體的內(nèi)存數(shù)據(jù),“”標(biāo)識(shí)你這個(gè)對(duì)象指向的內(nèi)存內(nèi)容是空字符串

查看完整回答
反對(duì) 回復(fù) 2017-08-04
  • 月亮島Superman
    月亮島Superman
    正因?yàn)椴恢赶蚓唧w內(nèi)存數(shù)據(jù)所以說(shuō)不可能 在頁(yè)面上顯示null啊 這是怎么回事呢
  • 2 回答
  • 0 關(guān)注
  • 1927 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)