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

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

有沒有好心人幫我看看這個關(guān)于Cookie的問題

首選時index.jsp頁面代碼:

<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>
? <%
?? long i=System.currentTimeMillis() ;
?? Date d=new Date(i);
?? SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日hh時mm分ss秒");
?String t=sdf.format(d);
? %>
? <body>
??? <h1>通過post方式傳遞一個參數(shù)給detail.jsp頁面</h1><br>
?? ?<form action="detail.jsp" method="post">
?? ??<table>
?? ???<tr>
?? ????<td><input type="text"? name="time"? value=<%=t %>></td>
?? ????<td><input type="submit" value="提交當(dāng)前時間"></td>
?? ???</tr>
?? ??</table>
?? ?</form>
? </body>
</html>



其次是detail.jsp頁面代碼:

<%@ 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>處理傳遞過來的參數(shù)</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>接受傳遞過來的參數(shù)</h1>
???? <%
???? ?request.setCharacterEncoding("utf-8");
???? ?String time= request.getParameter("time");//接受傳遞過來的參數(shù)
????
???? %>
??? 傳遞過來的參數(shù)是:<%=time %><br>
??? <%
??? ?//將傳遞過來的參數(shù)保存到Cookie中
??? ?//直接創(chuàng)建Cookie對象,就會導(dǎo)致每一訪問的時候都會創(chuàng)建一個最新的Cookie對象,
??? ?//所以我們可以先判斷有沒有Cookie對象,并將要保存的值先保存到一個字符串變量中,
??? ?//然后再取出
??? ?Cookie[] cookies=request.getCookies();
??? ?if(cookies !=null && cookies.length>0){
??? ??for(Cookie c:cookies){
??? ??time +=?"<br>"+c.getValue()+"#";//將cookie對象的值保存到time變量中,并以“#”分割
??? ??}
??? ?}
??? ?Cookie cookie=new Cookie("timecookie",time);
???
??? ?response.addCookie(cookie);
???? %>
???? <a href="cookie.jsp">在同一次會話中獲取保存的cookie</a>
? </body>
</html>



然后是cookie.jsp頁面代碼:

<%@ 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 'cookie.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>
??? <%
??? String creatCookieTime=null;
??? ?Cookie[] cookies=request.getCookies();
??? ?for(Cookie c:cookies){
??? ??if(c.getName().equals("timecookie")){
??? ???creatCookieTime=c.getValue();
??? ???out.println("獲得Cookie對象"+creatCookieTime);
??? ??}
??? ?}
??? ?String[] arr=creatCookieTime.split("#");
??? ?if(arr !=null && arr.length>0){
??? ??for(String s:arr){
??? ??
??? ?%>
??? <p>Cookie的創(chuàng)建時間是<%=s%><br></p>
??? <%
? ? ? } ? ?
??? ?}
???? %>?
? </body>
</html>

運行結(jié)果是:http://img1.sycdn.imooc.com//5aae66610001c94611520648.jpg

正在回答

2 回答

https://img1.sycdn.imooc.com//5b30fcd80001409703300042.jpg

這里是想獲取ID嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~

發(fā)現(xiàn)你的一個錯誤http://img1.sycdn.imooc.com//5ab283d50001c5ef09690531.jpg

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

如果我是DJ我是DJ我是DJ我是DJ

這個有啥問題嗎 ..不是打印T咩
2018-06-25 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

有沒有好心人幫我看看這個關(guān)于Cookie的問題

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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