javaservlet运行后出现空白界面
package edu.hebeu.Servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class doLodin
*/
@WebServlet("/login")
public class doLodin extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public doLodin() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
this.doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String username=request.getParameter("username");
String pwd=request.getParameter("pwd1");
System.out.println(username+" "+pwd);
boolean flag=false;
if(username.indexOf("ma")>=0 && pwd.equals("123456")){
flag=true;
}
if(flag){
HttpSession s1=request.getSession();
s1.setAttribute("username", username);
response.sendRedirect(request.getContextPath()+"/admin/success.jsp");
}
else{
request.getRequestDispatcher("/admin/login.jsp").forward(request,response);}
}
}
login.jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath %>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function back() {
location.href="login.jsp";
}
</script>
</head>
<body>
<h3>登录界面</h3>
<form action="/chapter/admin/login.jsp" method="post">
用户名:<input type="text" name="username" id="username"><br>
密码:<input type="password" name="pwd1" id="pwd2"><br>
<input type="submit" value="登录">
</form>
</body>
</html>
success.jsp代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
登陆成功!<%=request.getAttribute("username") %>
</body>
</html>
web.xml的配备
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>chapter</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>a</servlet-name>
<servlet-class>edu.hebeu.Servlet.doLodin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>a</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>
帮忙看看是哪里出现了错误