这是第一个页面
<%@ 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 'index.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>
<form name=test action=admin.jsp method="post">
<div id=t>
<label>账号:</label><input type="text"name=username value="">
<label>密码</label><input type="password" name="password" value="">
<input type="submit"value="登录">
</div>
</form>
</body>
</html>这是提交的页面<%@ 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+"/";String name=request.getParameter("username");String password=request.getParameter("password");request.setCharacterEncoding("utf-8");if("admin".equals(name)&&"admin".equals(password)){ request.getRequestDispatcher("admin1").forward(request,response);}else{ response.sendRedirect("admin2");}%>admin1和2我都什么都没写,但是点了转发或者重定向都会出错<%@ 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+"/";%>
添加回答
举报
0/150
提交
取消