欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

8.用户模块:跳转到登录页面_html/css_WEB-ITnose

程序员文章站 2022-04-22 08:42:49
...
1、在menu.jsp页面,修改登录的链接。
<a href="${pageContext.request.contextPath }/user_loginPage.action">登录</a>|

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><p class="span10 last">	
<p class="topNav clearfix">	
<ul>	
<li id="headerLogin" class="headerLogin" style="display: list-item;">	
<a href="${pageContext.request.contextPath }/user_loginPage.action">登录</a>|	
</li>	
<li id="headerRegister" class="headerRegister" style="display: list-item;">	
<a href="${pageContext.request.contextPath }/user_registPage">注册</a>|	</li>	
<li id="headerUsername" class="headerUsername"></li>	
<li id="headerLogout" class="headerLogout">	
<a>[退出]</a>|	</li>	
<li>	
<a>会员中心</a>	|	
</li>	
<li>	
<a>购物指南</a>	|	
</li>	

<li>	
<a>关于我们</a>	</li>	
</ul>	
</p>	
<p class="cart">	
<a  href="./购物车.htm">购物车</a>	
</p>	
<p class="phone">	
客服热线:				
<strong>96008/53277764</strong>	</p>	
</p>	
<p class="span24">	

<ul class="mainNav">	
<li>	
<a href="./index.htm">首页</a>	|	
</li>	
<li>	
<a href="./蔬菜分类.htm">定制套餐</a>	|	
</li>	<li>	<a >安全频道</a>	
| </li>	<li>	
<a>商城卡</a>	|	</li>	<li>	
<a>蔬菜基地</a>	|	
</li>	
<li>	
<a>节气养生</a>	|	
</li>	<li>	
<a>便民服务</a>	| </li>	</ul>	</p>

2、在UserAction中增加loginPage方法

/** * 转向到登录页面 * @return */public String loginPage(){return "loginPage";}

3、在struts.xml中增加loginPage的配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"	
"http://struts.apache.org/dtds/struts-2.3.dtd"><struts>    
<package name="shop" namespace="/" extends="struts-default">    	
<action name="index" class="indexAction">    	
<result name="index">/WEB-INF/jsp/index.jsp</result>    	
</action>    	   	
<!-- 用户action -->    	
<action name="user_*" class="userAction" method="{1}">    	
<result name="registPage">/WEB-INF/jsp/regist.jsp</result>    	
<result name="input">/WEB-INF/jsp/regist.jsp</result>    	
<result name="msg">/WEB-INF/jsp/msg.jsp</result>    	
<result name="loginPage">/WEB-INF/jsp/login.jsp</result>    	
</action>    
</package></struts>

4、增加login.jsp

里面包含

<%@include file="menu.jsp" %>
<%@ page language="java" import="java.util.*" 
pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
" 
<!-- 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"/></head><body><p class="container header">	
<p class="span5">	
<p class="logo">	
<a href=" 
<img src="${pageContext.request.contextPath}/image/r___________renleipic_01/logo.gif" alt="商城">	
</a>	
</p>	
</p>	
<p class="span9"><p class="headerAd">	
<img src="${pageContext.request.contextPath}/image/header.jpg" 
width="320" 
height="50" 
alt="正品保障" 
title="正品保障"></p>	
</p>	
<%@include file="menu.jsp" %>	
</p>	
<p class="container login">	
<p class="span12"><p class="ad">	
<img src="${pageContext.request.contextPath}
/image/login.jpg" 
width="500" 
height="330" 
alt="会员登录" 
title="会员登录"></p>	
</p>	
<p class="span12 last">	<p class="wrap">	
<p class="main">	
<p class="title">	
<strong>会员登录</strong>USER LOGIN </p>	
<form id="loginForm"  method="post" novalidate="novalidate">	
<table>	<tbody><tr>	<th>	用户名/E-mail:	</th>	<td>	
<input 
type="text" 
id="username" 
name="username" 
class="text" 
maxlength="20">	
</td>	</tr>	<tr>	<th>	密  码:	</th>	<td>	
<input 
type="password" 
id="password" 
name="password" 
class="text" 
maxlength="20" 
autocomplete="off">	
</td>	</tr>	<tr>	<th>	验证码: </th>	<td>	
<span class="fieldSet">	
<input 
type="text" 
id="captcha" 
name="captcha" 
class="text captcha" 
maxlength="4" 
autocomplete="off"><img 
id="captchaImage" 
class="captchaImage" 
src="${pageContext.request.contextPath}/image/captcha.jhtml" 
title="点击更换验证码">	
</span>	
</td>	
</tr>	
<tr> <th> </th>	<td>	
<label>	<input type="checkbox" id="isRememberUsername" name="isRememberUsername" value="true">记住用户名	
</label>	
<label>	 
<a >找回密码</a>	
</label>	
</td>	
</tr>	
<tr>	
<th> </th>	
<td>	
<input type="submit" class="submit" value="登 录">	
</td>	</tr>	
<tr class="register">	
<th> </th>	
<td>	
<dl>	
<dt>还没有注册账号?</dt>	
<dd>	
立即注册即可体验在线购物!	
<a href="./会员注册.htm">立即注册</a>	
</dd>	</dl>	</td>	</tr> </tbody></table>	</form>	</p>	</p>	</p>	
</p><p class="container footer">	<p class="span24">	 
<p class="footerAd"><img src="${pageContext.request.contextPath}
/image/footer.jpg" 
width="950" 
height="52" 
alt="我们的优势" 
title="我们的优势" /></p>	</p>	
<p class="span24">	
<ul class="bottomNav">	
<li>	
<a >关于我们</a>	
|	
</li> <li>	
<a>联系我们</a>	
|	
</li>	
<li>	
<a>招贤纳士</a>	
|	
</li>	
<li>	
<a>法律声明</a>	
|	
</li>	
<li>	
<a>友情链接</a>	
| 
</li>	
<li>	
<a target="_blank">支付方式</a>	
|	
</li>	
<li>	
<a  target="_blank">配送方式</a>	
|	
</li>	
<li>	
<a>服务声明</a>	
|	
</li>	
<li>	
<a>广告声明</a>	
</li>	
</ul>	
</p>	
<p class="span24">	
<p class="copyright">Copyright © 2005-2015 网上商城 版权所有</p>	
</p></p></body></html>

5、效果图