问答详情
源自:4-11 阶段案例——实现用户登录

Status report message /login/login_success.jsp description The requested resource is not available.

为什么到了dologin为止就找不到文件了

<%@ 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+"/";


request.setCharacterEncoding("utf-8");

String name="";

name=request.getParameter("username");

String password="";

password=request.getParameter("password");

if("admin".equals(name)&&"admin".equals(password)){

session.setAttribute("name",name);

request.getRequestDispatcher("login_success.jsp").forward(request,response);

}else{

response.sendRedirect("login_failure.jsp");


}

%>





<%@ 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 'login.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>

  

 <% 

 String name="";

 if(session.getAttribute("name")!=null){

 name=session.getAttribute("name").toString();

 }

 %>

  欢迎<font color="red"><%=name %></font>,登录成功!

 

  

  </body>

</html>


提问者:慕粉4039862 2016-10-13 10:35

个回答

  • tinylight
    2016-10-13 11:22:19

    你检查一下你的form表单,看他提交到哪里