亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么添加了判斷語句后愛好什么都沒有顯示

<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

? <head>

? ? <base href="<%=basePath%>">

? ??

? ? <title>My JSP 'request.jsp' starting page</title>

? ??

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0"> ? ?

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->


? </head>

??

? <body>

<h1>request內置對象</h1>

<%

request.setCharacterEncoding("UTF-8");

request.setAttribute("password", "123456");

%>

用戶名:<%=request.getParameter("username") %><br>

愛好:<% ?

if(request.getParameterValues("favortie")!=null){

String[] favorites = request.getParameterValues("favorite");

for(int i=0;i<favorites.length;i++)

{

out.println(favorites[i]+"&nbsp;&nbsp;");

}

}

%>

密碼:<%=request.getAttribute("password") %><br>

請求體的MIME類型:<%=request.getContentType() %><br>

協議類型及版本號:<%=request.getProtocol() %><br>

服務器主機名:<%=request.getLocalName() %><br>

服務器端口號:<%=request.getLocalPort() %><br>

請求文件的長度:<%=request.getContentLength() %><br>

請求客戶端的IP地址:<%=request.getLocalAddr() %><br>

請求的真實路徑:<%=request.getRealPath("request.jsp") %><br>

請求上下文的路徑:<%=request.getContextPath() %><br>

? </body>

</html>






<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

? <head>

? ? <base href="<%=basePath%>">

? ??

? ? <title>My JSP 'reg.jsp' starting page</title>

? ??

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0"> ? ?

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->


? </head>

??

? <body>

? ? <h1>用戶注冊</h1>

? ? <hr>

? ? <form action="response.jsp" name="regForm" method="post">

? ? <table>

? ? <tr>

? ? <td>用戶名:</td>

? ? <td><input type="text" name="username"/></td>

? ? </tr>

? ? <tr>

? ? <td>愛好:</td>

? ? <td>

? ? <input type="checkbox" name="favorite" value="read"/>讀書

? ? <input type="checkbox" name="favorite" value="music"/>音樂

? ? <input type="checkbox" name="favorite" value="movie"/>電影

? ? <input type="checkbox" name="favorite" value="internet"/>上網

? ? </td>

? ? </tr>

? ? <tr>?

? ? <td colspan="2"><input type="submit" value="提交"/></td>

? ? </tr>

? ?

? ? </table>

? ? </form>

? ? <br>

? ? <br>

? ? <a href="request.jsp?username= 李四 " >測試URL傳參數</a>

??

? </body>

</html>

求大神看看為什么添加了判斷語句后愛好沒有顯示????

正在回答

1 回答

if(request.getParameterValues("favortie")!=null) 你指的是這句么?

如果你沒勾選愛好肯定是不會顯示了,或者點擊超鏈接也沒有,因為超鏈接沒傳遞愛好,添加這句只是為了防止報空指針異常?out.println(favorites[i]+"&nbsp &nbsp");

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么添加了判斷語句后愛好什么都沒有顯示

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號