国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

JSP 頁面傳值

2019-11-14 22:51:37
字體:
來源:轉載
供稿:網友
jsp 頁面傳值使用session會話傳值并重定向頁面
 //得到用戶提交的值 String name = request.getParameter("username"); String pwd = request.getParameter("passWord"); //創建HttpSessio對象 HttpSession s = request.getSession(); //將值綁定在session會話中 s.setAttribute("Sname",name); s.setAttribute("Spwd",pwd); //重定向 response.sendRedirect("yinyu.jsp");

在yinyu.jsp頁面中得到值

//使用session會話取值
String username = (String)session.getAttribute("Sname"); String password = (String)session.getAttribute("Spwd");或者
${Sname}; ${Spwd};

使用request方式傳值并頁面轉發
 //得到用戶提交的值 String name = request.getParameter("username"); String pwd = request.getParameter("password"); //將值綁定在request中 request.setAttribute("Rname",name); request.setAttribute("Rpwd",pwd); //頁面轉發 RequestDispatcher rd = request.getRequestDispatcher("yinyu.jsp"); rd.forward(request,response);

在yinyu.jsp頁面中得到值

 //使用request協助相關取值
String username = (String)request.getAttribute("Rname"); String password = (String)request.getAttribute("Rpwd");或者${Sname};
 ${Spwd};

setAttribute()設置綁定屬性值setAttribute("自定義命名",要綁定的引用);
getAttribute()取出得到屬性值getAttribute("setAttribute中的自定義命名");
sendRedirect()重定向跳轉頁面sendRedirect("要跳轉的頁面地址");

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 文安县| 麻江县| 石河子市| 哈巴河县| 久治县| 始兴县| 伊金霍洛旗| 乃东县| 漾濞| 漠河县| 湘潭市| 那坡县| 营山县| 曲阳县| 吉林省| 斗六市| 遵化市| 丹巴县| 枞阳县| 库尔勒市| 余庆县| 长岛县| 那曲县| 鄂尔多斯市| 盈江县| 阳曲县| 虞城县| 潮州市| 称多县| 镇远县| 耒阳市| 齐齐哈尔市| 濮阳县| 广饶县| 阿拉善右旗| 苍南县| 玉门市| 大同县| 深州市| 奉化市| 高邑县|