這是第一個(gè)頁面
<%@?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>賬號(hào):</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我都什么都沒寫,但是點(diǎn)了轉(zhuǎn)發(fā)或者重定向都會(huì)出錯(cuò)<%@ 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+"/";%>
2 回答
已采納

qq_連環(huán)_04358155
TA貢獻(xiàn)34條經(jīng)驗(yàn) 獲得超5個(gè)贊
admin1和2是jsp嗎,如果是沒有后綴啊,而且提交的頁面一般都是servlet,這樣才好處理內(nèi)容啊
添加回答
舉報(bào)
0/150
提交
取消