用户登录业务:
1、用户登录页面点击登录校验用户名和密码不能为空!
2、登录失败页面不跳转,显示登录失败错误信息!
3、登录成功跳转到首页,首页显示登录人的姓名。
-------------------------相关代码-----------------------------------
1、login.jsp
首先提交执行函数checkForm进行用户名和密码的校验,然后提交到action="${pageContext.request.contextPath }/user_login.action",代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0080)http://localhost:8080/mango/login.jhtml?redirectUrl=%2Fmango%2Fcart%2Flist.jhtml -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>会员登录</title>
<link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function checkForm(){
//用户名校验
var username = document.getElementById("username").value;
if(username==null || username==''){
alert("用户名不能为空");
return false;
}
//密码校验
var password = document.getElementById("password").value;
if(password==null || password==''){
alert("密码不能为空");
return false;
}
}
</script>
</head>
<body>
<div class="container header">
<div class="span5">
<div class="logo">
<a href="http://localhost:8080/mango/">
"<img src="${pageContext.request.contextPath}/image/r___________renleipic_01/logo.gif" alt=