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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這個為什么不能運(yùn)行

這個為什么不能運(yùn)行

id路人 2016-09-22 18:05:43
這個是jsp的文件------------------------------------------------------------------------------------------------------------<%@ page language="java" import="java.net.URLDecoder" pageEncoding="utf-8"%><%String username="";String password="";Cookie cookies[]=request.getCookies();if(cookies!=null){? for(int i=0;i<=cookies.length;i++){? ? ? if(cookies[i].getName().equals("Name")){? ? ? ? ? ? username=URLDecoder.decode(cookies[i].getValue(),"utf-8");? ? ? ? ? ? };? ? ? if(cookies[i].getName().equals("Password")){? ? ? ? ? ? password=cookies[i].getValue();? ? ? ? ? ? };? ? ? };};%><html><head><title>登陸頁面</title></head><body><form action="LoginServlet" method="post">用戶名:<input type="text" name="username" value="<%out.print(username); %>">密碼:<input type="password" name="password" value="<%out.print(password); %>">Cookies:<select name="cookietime"><option value="0">不保存</option><option value="1">一整天</option><option value="30">一整月</option><option value="365">一整年</option></select><input type="submit" name="login" value="登陸"><input type="reset" value="重置"></form></body></html>下面這個是java的文件------------------------------------------------------------------------------------------------------import java.io.*;import java.net.URLEncoder;import java.util.Calendar;import java.util.Date;import javax.servlet.*;import javax.servlet.http.*;public class LoginServlet extends HttpServlet { public LoginServlet() { super(); } public void destroy() { super.destroy(); } public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {? ? ? ?? req.setCharacterEncoding("utf-8"); String cookietime=req.getParameter("cookietime"); int cookietimes=Integer.parseInt(cookietime.trim()); Cookie c=new Cookie("Name",URLEncoder.encode(req.getParameter("username"),"utf-8")); c.setMaxAge(cookietimes*60*60*24); c.setPath("/"); res.addCookie(c); Cookie a=new Cookie("Password",req.getParameter("password")); a.setMaxAge(cookietimes*68*60*24); a.setPath("/"); res.addCookie(a); Calendar calendar=null; String message=null; calendar=Calendar.getInstance(); Date trialTime=new Date(); calendar.setTime(trialTime); int hour=calendar.get(Calendar.HOUR_OF_DAY); if(hour<12){ message="Good morning!"; } else{ message="Good afternoon!"; } if(req.getParameter("username").equals("張三")&&req.getParameter("password").equals("1234")){ req.setAttribute("message", message); req.getRequestDispatcher("/MyJsp.jsp").forward(req, res); } else { res.sendRedirect("http://localhost:8080/index1/index.jsp?message=sorry please register"); } } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { this.doGet(req, res); } public void init() throws ServletException { }}
查看完整描述

1 回答

?
逆光之羽

TA貢獻(xiàn)55條經(jīng)驗(yàn) 獲得超13個贊

java.lang.ArrayIndexOutOfBoundsException: 1

報(bào)的異常是這個?

//jsp里這兒把等號去掉
for(int?i=0;i<cookies.length;i++){


查看完整回答
反對 回復(fù) 2016-09-30
  • 1 回答
  • 0 關(guān)注
  • 1484 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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