jsp文件
1.index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Index Page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<jsp:forward page="login.jsp"></jsp:forward>
</body>
</html>
2.login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Index Page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<s:fielderror></s:fielderror>
<s:form action="login">
<s:textfield name="user.username" label="用 户"></s:textfield>
<s:password name="user.password" label="密 码"></s:password>
<s:submit value="登录"></s:submit>
</s:form>
</body>
</html>
3.login_success.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Index Page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<c:choose>
<c:when test="${empty user}">您还没有登录哦。。。</c:when>
<c:otherwise>${user.username},欢迎登录</c:otherwise>
</c:choose>
</body>
</html>
附图
注意:运行本项目需要jstl标签库的支持,如果你使用的是java ee 5的话就不需要另外引入了
posted on 2009-07-29 16:33
jadmin 阅读(97)
评论(0) 编辑 收藏