濮阳杆衣贸易有限公司

主頁 > 知識庫 > jsp response.sendRedirect()用法詳解

jsp response.sendRedirect()用法詳解

熱門標簽:自繪地圖標注數(shù)據(jù) 電銷機器人免培訓 電話機器人需要使用網(wǎng)絡嗎 南通通訊外呼系統(tǒng)產(chǎn)品介紹 海外圖書館地圖標注點 外呼系統(tǒng)使用方法 給地圖標注得傭金 潤滑油銷售電銷機器人 如何看懂地圖標注點

sendRedirect()

response和request一樣都是jsp內置對象,request是獲取用戶的請求,response處理用戶請求。sendRedirect()函數(shù)的作用是重定向網(wǎng)頁,向瀏覽器發(fā)送一個特殊的Header,然后由瀏覽器來做重定向,轉到指定的頁面。下面我將創(chuàng)建四個頁面,首先是sex.jsp,有一個下拉列表和提交按鈕確定,選擇“男”,就跳轉到male.jsp,選擇“女”就跳轉到female.jsp,中間通過sex_action.jsp進行重定向

!-- sex.jsp -->
%@ page language="java" import="java.util.*" pageEncoding="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%>" rel="external nofollow"  rel="external nofollow" >

title>Sex Select's 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">
/head>
body>
	form action="%=basePath%>c03/sex_action.jsp" method="post">
		select name="sex">
			option>男/option>
			option>女/option>
		/select>
		button type="submit">提交/button>
	/form>
/body>
/html>
!-- sex_action.jsp -->
%@ page language="java" import="java.util.*" pageEncoding="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%>" rel="external nofollow"  rel="external nofollow" >

title>My JSP 'sex_action.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">
/head>
body>
	% 
    	request.setCharacterEncoding("UTF-8");
    	String sex = request.getParameter("sex");
    	out.println(sex);
    	if("男".equals(sex)) {
    		response.sendRedirect("male.jsp");
    		return;
    	}
    	else if("女".equals(sex)) {
    		response.sendRedirect("female.jsp");
    		return;
    	}
    %>
/body>
/html>

到此這篇關于jsp response.sendRedirect()用法詳解的文章就介紹到這了,更多相關jsp response.sendRedirect()內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • response.setContentType()參數(shù)以及作用詳解
  • Response.AddHeader案例講解
  • 如何使用spring ResponseEntity處理http響應
  • jsp Response對象頁面重定向、時間的動態(tài)顯示
  • JavaWeb入門:HttpResponse和HttpRequest詳解
  • Flask response響應的具體使用
  • ResponseBodyAdvice踩坑及解決
  • 基于@RequestBody和@ResponseBody及Stringify()的作用說明

標簽:內江 貸款邀約 大連 樂山 南京 黃石 銅川 廣州

巨人網(wǎng)絡通訊聲明:本文標題《jsp response.sendRedirect()用法詳解》,本文關鍵詞  jsp,response.sendRedirect,用法,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《jsp response.sendRedirect()用法詳解》相關的同類信息!
  • 本頁收集關于jsp response.sendRedirect()用法詳解的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    韩城市| 和硕县| 天全县| 章丘市| 宜春市| 武安市| 通江县| 福贡县| 巴塘县| 常山县| 泰宁县| 汝州市| 通山县| 南靖县| 宜兰市| 西藏| 福鼎市| 毕节市| 敦煌市| 郸城县| 安阳县| 沽源县| 景泰县| 略阳县| 武定县| 柯坪县| 辽阳市| 通化市| 安丘市| 拉孜县| 紫阳县| 雅安市| 景谷| 疏附县| 涿鹿县| 且末县| 普宁市| 喀喇| 霍州市| 丰城市| 图片|