zoukankan      html  css  js  c++  java
  • controller分支实现前台显示弹框同时转发

    controller分支实现前台显示弹框,前台不需要进行什么操作,  前台请求后台的分支即可。

    controller层(标红的地方是(alert('账号或密码错误!请重新输入!!!!')        window.location.href='/index.jsp'):弹出一个弹框,然后跳转一个页面,如果你只想弹个弹框可以把跳转的页面去掉。):

     @RequestMapping("/isLogin")
        public Object isLogin(HttpServletRequest request, String uname, String upwd, HttpServletResponse response) throws IOException {
            Userinfo userinfo=new Userinfo();
            userinfo.setUname(uname);
            userinfo.setUpwd(upwd);
            Userinfo login = service.login(userinfo);
            response.setContentType("text/html;charset=utf-8");
            PrintWriter out=response.getWriter();
            if (login!=null){
                System.out.println("0");
                return "/index.jsp";
            }else {
                //out.print("<script language="javascript">alert('登录失败!');</script>");
                out.print("<script language="javascript">alert('账号或密码错误!请重新输入!!!!');window.location.href='/index.jsp'</script>");
                System.out.println("1");
                return out;
            }
    
        }
    

      页面:

    <%@ page language="java" contentType="text/html; utf-8" isELIgnored="false" pageEncoding="utf-8" %>
    
    <html>
    <title>我是登录</title>
    <body>
    <h2>Hello World!</h2>
    
    
    <form action="/isLogin" method="post" >
        用户:<input type="text" name="uname"><br>
        密码:<input type="text" name="upwd"><br><br>
        <input type="submit" value="确定登录">
                   <button><a href="uen.jsp">点击注册</a></button>
    </form>
    
    </body>
    </html>
    

     

     转载:https://www.cnblogs.com/SHANKS-log/p/5031758.html

  • 相关阅读:
    网易企业免费邮箱
    168. Excel Sheet Column Title
    167.Two Sum II-Input array is sorted
    166. Fraction to Recurring Decimal
    165 Compare Version Numbers
    164. Maximum Gap
    163.Missing Ranges
    162.Find Peak Element
    161.One Edit Distance
    160. Intersection of Two Linked Lists
  • 原文地址:https://www.cnblogs.com/java-263/p/10408372.html
Copyright © 2011-2022 走看看