jsp response.sendRedirect()用法详解(jspresponse对象实现用户登录)没想到

随心笔谈12个月前发布 admin
90 0


<!– 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=”https://www.jb51.net/article/<%=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>

© 版权声明

相关文章