用Ajax前后端分离实现一个简单的用户登录页面
先看一下页面效果图
账号和密码格式错误
格式正确但是用户名或密码错误(清空密码框内容,选中账号框全部内容)
程序详解:
@: 对输入的账号和密码用正则表达式验证格式
@@: 格式错误会提示让你输入正确的格式
@@@: 验证输入的账号密码是否正确
@@@@: 不正确密码清空账号输入框的内容全部被选中
@@@@@: 账号和密码都正确会跳转到另外一个页面
- 看一下文件的布局结构
- index.jsp代码
<%@ page language="java" import="java.util.*" 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">
<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>
<style>
body{
text-align: center;
float: center;
background-image: url(img/2.jpg);
}
#big{
width: 60%;
height: 500px;
border: 1px #F9FBF8 solid;
margin: 120px auto;
background-image: url(img/3.jpg);
opacity: 0.7;