zoukankan      html  css  js  c++  java
  • 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>
     <%
    String name=request.getParameter("name");
    
    String password=request.getParameter("password");
    
    %>
        
    <% 
    if(name.equals("test")&&password.equals("56789"))
    {
    
        out.print("账号密码正确");
    
        
    }else{
    
    response.sendRedirect("homeworkerror.jsp");
        
      
    }
    %>
    
    
    </body>
    </html>

    用户输入页:

    <%@ 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>
    <form action="homework0624-2.jsp" method="post">
    
    账号:<input type="text" name="name" >
    <br>
    密码:<input type="password" name="password" >
    <br>
    <input type="submit" value="提交">
    
    
    </form>
    </body>
    </html>

    错误页:

    <%@ 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>错误页面</title>
    </head>
    <body>
    您的输入有误,请重新输入...

    <%
    response.setHeader("refresh", "10;URL=homework0624.jsp");
    %>

    </body>
    </html>

    运行结果:

    正确登录:

    错误登录:

  • 相关阅读:
    fiddler无法抓取360浏览器包的问题
    腾讯云服务器上发送邮件连接超时(无法发送)的相关问题
    jQuery获取后台动态添加上去的选择器
    NOIP 模拟 $84; m 宝藏$
    NOIP 模拟 $83; m 铺设道路$
    NOIP 模拟 $83; m 传统艺能$
    NOIP 模拟 $83; m 时代的眼泪$
    NOIP 模拟 $83; m 树上的数$
    NOIP 模拟 $80; m 百鸽笼$
    NOIP 模拟 $80; m 滑稽树下你和我$
  • 原文地址:https://www.cnblogs.com/miss123/p/5614709.html
Copyright © 2011-2022 走看看