咸鱼入门到放弃11--Servlet+JSP+JavaBean开发模式
本篇搬运了大佬blog:https://www.cnblogs.com/xdp-gacl/p/3902537.html
一、Servlet+JSP+JavaBean开发模式(MVC)介绍
Servlet+JSP+JavaBean模式(MVC)适合开发复杂的web应用,在这种模式下,servlet负责处理用户请求,jsp负责数据显示,javabean负责封装数据。 Servlet+JSP+JavaBean模式程序各个模块之间层次清晰,web开发推荐采用此种模式。
这里以一个最常用的用户登录注册程序来讲解Servlet+JSP+JavaBean开发模式,通过这个用户登录注册程序综合案例,把之前的学过的XML、Xpath、Servlet、jsp的知识点都串联起来。
二、创建MVC架构的Web项目
在MyEclipse中新创建一个webmvcframework项目,导入项目所需要的开发包(jar包),创建项目所需要的包,在java开发中,架构的层次是以包的形式体现出来的
项目所需要的开发包(jar包) | ||
序号 | 开发包名称 | 描述 |
1 | dom4j-1.6.1.jar | dom4j用于操作XML文件 |
2 | jaxen-1.1-beta-6.jar | 用于解析XPath表达式 |
3 | commons-beanutils-1.8.0.jar | 工具类,用于处理bean对象 |
4 | commons-logging.jar | commons-beanutils-1.8.0.jar的依赖jar包 |
5 | jstl.jar | jstl标签库和EL表达式依赖包 |
6 | standard.jar | jstl标签库和EL表达式依赖包 |
项目所需要的包 | |||
序号 | 包名 | 描述 | 所属层次 |
1 | me.gacl.domain | 存放系统的JavaBean类(只包含简单的属性以及属性对应的get和set方法,不包含具体的业务处理方法),提供给【数据访问层】、【业务处理层】、【Web层】来使用 | domain(域模型)层 |
2 | me.gacl.dao | 存放访问数据库的操作接口类 | 数据访问层 |
3 | me.gacl.dao.impl | 存放访问数据库的操作接口的实现类 | |
4 | me.gacl.service | 存放处理系统业务接口类 | 业务处理层 |
5 | me.gacl.service.impl | 存放处理系统业务接口的实现类 | |
6 | me.gacl.web.controller | 存放作为系统控制器的Servlet | Web层(表现层) |
7 | me.gacl.web.UI | 存放为用户提供用户界面的servlet(UI指的是user interface) | |
8 | me.gacl.web.filter | 存放系统的用到的过滤器(Filter) | |
9 | me.gacl.web.listener | 存放系统的用到的监听器(Listener) | |
10 | me.gacl.util | 存放系统的通用工具类,提供给【数据访问层】、【业务处理层】、【Web层】来使用 | |
11 | junit.test | 存放系统的测试类 |
一个良好的JavaWeb项目架构应该具有以上的11个包,这样显得层次分明,各个层之间的职责也很清晰明了,搭建JavaWeb项目架构时,就按照上面的1~11的序号顺序创建包:domain→dao→dao.impl→service→service.impl→web.controller→web.UI→web.filter→web.listener→util→junit.test,包的层次创建好了,项目的架构也就定下来了,当然,在实际的项目开发中,也不一定是完完全全按照上面说的来创建包的层次结构,而是根据项目的实际情况,可能还需要创建其他的包,这个得根据项目的需要来定了
在src目录(类目录)下面,创建用于保存用户数据的xml文件(DB.xml)
在WEB-INF目录下创建一个pages目录,pages目录存放系统的一些受保护(不允许用户直接通过URL地址访问)的jsp页面,用户要想访问这些受保护的jsp页面,那么只能通过me.gacl.web.UI这个包里面的Servlet
创建好的项目如下图(图-1)所示:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdYAAAI0CAIAAAAvHJ8ZAAAgAElEQVR4nO2df5DUxoHvVVeVv00qV5XzH6/wOYkPx3Vw4SWpeqoUy717L8C7PyB2rQMXJ3A2EeaROMZ2KjiJ2QUDt8F20Nng4BCza8eL1wYTYoJizoFZ7AObi8/Gv+I99PCy/DCwv7zB/Jjlh/r9oRmpW+qWNDOaUffo+6kuakajlnqY2c/2tlr91QgAAICM0Opx0P7+QltnZ0tnoa2zs7+/UI9TAABAE5C+gvv7Cy2FwvxCobe3t6vrmZbOAiwMAABcUlDw2y/c7xVCSFuhML+z0FnoLPS3FQqd89sK89s6az6JbeqaYdV8mMjja1pdT1E79f5PAAA0mloVfGjb/ezTZS2dhd7e3kJhfltnS1tnS0tbS8v8zhrPUm/7KOI2RZoJAEhMlQresOJnG1b8bMOKjktnNl86s/lC/+PDbz90fN8D//Xi0rbOzrbOQltnW9v8lvlt81vmt7W1tdXczvraxzI03bTrdfTUgIIBaDaiFFwoFDo6Orgv/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9y4nh8RPD4552P3P99IV3lzZueepfoirHKJi96mYGRoCZC2ic8LewgunjUdfnOJlyAIAco5KCf925dmCwODBYdDu/bnlm28vuxl93rs26gdGjCxh5AAAEUUnBnb96pP9Msf9M8ZltL3v+dbd8eLrY+auapwPXTOTNcVAwACCISgre9Mt1/+/URVHZ9Mt1WTauNO4Q4VgoGAAQRCUFb9z4r9El6wYCAEBlqKRgAABoMqBgAADIDCgYAAAyAwoGAIDMgIIBACAzmkHByI4DACiKSgquKTtOCZB7BEDOUEzB1WfHKQEUDEDOUEnBjcuOAwCAhqCSghuXHQcAAA1BJQXXlB3nrlFplVaeNCx/NUlufJx4rUrOFt4m+mjs6pe8sxD/OIieAyBHqKTgmrLjXPHRcUS02Uo7hGLiwkvrcEPhjHI9f4X3iDXgOWF0wYMjeg6AfKCSgmvKjmPcx3vMj4kLBxTxI4uCndaKw+i8oyB6DoAcoZKCa8qOS6LgyKV+w0LU/KQMOkYjTsERUx4QPQdAzlBJwTVlx8UqmBsTF46AC2+hDkYlwlUSRofoOQDyikoKrik7Ll7B/Ktq4etf3FC40qiCYeisJjmX4/gX+BA9B0AeUUnBCmTHiYgef/BA9BwAOUMlBcufHUdhmzrTk05qYETPAZAnVFKw1NlxYagBh3j/InoOgFyikoKRHQcAaDJUUjAAADQZUDAAAGQGFAwAAJkBBQMAQGZAwQAAkBlQMAAAZAYUDAAAmfH/AY0DPCOgxuWXAAAAAElFTkSuQmCC" alt="" />
图-1
三、分层架构的代码编写
分层架构的代码也是按照【域模型层(domain)】→【数据访问层(dao、dao.impl)】→【业务处理层(service、service.impl)】→【表现层(web.controller、web.UI、web.filter、web.listener)】→【工具类(util)】→【测试类(junit.test)】的顺序进行编写的。
3.1、开发domain层
在me.gacl.domain包下创建一个User类
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIgAAAAoCAIAAACqxCXrAAAHj0lEQVRoge1aW08bRxSef5HHqKkaRUGVYrBpu6Uo/yAvTcBpolStNOpFVaCXRNzF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AM8tMFiYYDGZ5x5w6+ZKP5e55mHf6nO/0OQVhfEzSx3KLDPf5SSNhhAVRXSHS6iDFFZE6gJTU1EmV/p5XbwWFnKq5KEQQEEoXmhHNJMvbp7KuEy/PB7l7Hqby/X5BFW+Qmw9y8yFuPpj89MTLGWKVR5RyS8h+aZV0zpqNhFHEEBASabn0jjE1zRzL23PMxx9UeGjOE+CGJ73Dk15PgPMEuLkA56E5TyDR8WGFiYVlZVtwHOVieXvyb62tcPsTs37O7U+4xb8Jtz8x60/M+hNttdstTIE9+OdPmJaaVxqOVzbWVDbWVDYo/jYer2w8XtlS88r2lSKegAW0XXDxa/+CtaIwBWr/AgPz68EfJ9+cAAAAAElFTkSuQmCC" alt="" />
User类具体代码如下:
1 package me.gacl.domain;
2
3 import java.io.Serializable;
4 import java.util.Date;
5 /**
6 * @author gacl
7 * 用户实体类
8 */
9 public class User implements Serializable {
10
11 private static final long serialVersionUID = -4313782718477229465L;
12
13 // 用户ID
14 private String id;
15 // 用户名
16 private String userName;
17 // 用户密码
18 private String userPwd;
19 // 用户邮箱
20 private String email;
21 // 用户生日
22 private Date birthday;
23
24 public String getId() {
25 return id;
26 }
27
28 public void setId(String id) {
29 this.id = id;
30 }
31
32 public String getUserName() {
33 return userName;
34 }
35
36 public void setUserName(String userName) {
37 this.userName = userName;
38 }
39
40 public String getUserPwd() {
41 return userPwd;
42 }
43
44 public void setUserPwd(String userPwd) {
45 this.userPwd = userPwd;
46 }
47
48 public String getEmail() {
49 return email;
50 }
51
52 public void setEmail(String email) {
53 this.email = email;
54 }
55
56 public Date getBirthday() {
57 return birthday;
58 }
59
60 public void setBirthday(Date birthday) {
61 this.birthday = birthday;
62 }
63 }
3.2、开发数据访问层(dao、dao.impl)
在me.gacl.dao包下创建一个IUserDao接口类,对于开发接口类,我习惯以字母I作类的前缀,这样一眼就看出当前这个类是一个接口,这也算是一种良好的开发习惯吧,通过看类名就可以方便区分出是接口还是具体的实现类。
aaarticlea/png;base64,iVBORw0KGgo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c+nDuFMjb5oBIYuVr6+20UBQH+hhJh6kArZ4elB2cmeNoH6QSVaP4ibyFU4qklG8z40P0gDQJ22p65N8K52UmJGMscODXKhHRrkzOzlaN4ODSa63pRvFrdQ2tPdioD+61Nke/+VlYB4z8XX/X5QJuQOiCsBcYUTVwLJP73/Cs4kdadLuRW8Nqh4zjeqdzBDF4szVX8jozjt0JDypcrZFpPaSh6qZoJ3fFlChkbaAOjzip95jTg4nFcnolrs8oXszFXOtpiIFWZLW9EX0rafk34Mosdrij76Q63LJ7r84tice2zO7fKLLr+47BddPtHlT1j/WIszy1j/ggcBfa64Jj8GS/uNw3IQzXkUdTTXOr2JJa/o9Cacyt+E05tY8iaWvInO5lqcWb661UEBE7xVXJPlEkNyBtGsR1F706utJ+vamuramupaib9tJ+vaTta1N72KM8tSV+TDJP23ols5Swnp7M3lee/mDx7079WKCtUPHjTv3Tx7c7lEkMYcgZEHPOvfyvUptaJMsf6tkQf87Yel+tEvKW3dfODvGVl66r9Jl5F6RpZuPvAnpa0SQapY8VaBVAZWgVQG9j/uWJ4Wu6WWYgAAAABJRU5ErkJggg==" alt="" />
IUserDao接口的具体代码如下:
1 package me.gacl.dao;
2
3 import me.gacl.domain.User;
4
5 public interface IUserDao {
6
7 /**
8 * 根据用户名和密码来查找用户
9 * @param userName
10 * @param userPwd
11 * @return 查到到的用户
12 */
13 User find(String userName, String userPwd);
14
15 /**
16 * 添加用户
17 * @param user
18 */
19 void add(User user);
20
21 /**根据用户名来查找用户
22 * @param userName
23 * @return 查到到的用户
24 */
25 User find(String userName);
26 }
对于接口中的方法定义,这个只能是根据具体的业务来分析需要定义哪些方法了,但是无论是多么复杂的业务,都离不开基本的CRUD(增删改查)操作,Dao层是直接和数据库交互的,所以Dao层的接口一般都会有增删改查这四种操作的相关方法。
在me.gacl.dao.impl包下创建一个UserDaoImpl类
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAAApCAIAAAA0+RUQAAAF0UlEQVR4nO2a32vbV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hTwdAZZiVCll/qekDQP7EgkksvlKuy8MHGxyL0Xt/Uo0/7l42/If979+2h71f926avF+xc17BoCW04wRdQMzIwn9I19/yHJBNihUGhhYSGdTlfS+Y/xS/kiny/yBZaXYOdZvsDyeZafv3dJw67BsFE7KpTtYCeTyenp6VgsZtj590BPtsBnC/xpQYadzfPZPJ8t8LOBHg07PdiocjF1IRtQ9oWTNIItsKeaAjQgMvNKz8DolMFAU7zcQMcMyRzYgiCk02mSJLe3t/U7Px3tyWT5TLaUycmwM7lSJssf5/ino59r2GnDRoxIZCEbXPalB7u6AjQYtkmlZ6CJOhgKeu+uHbNSpsEWBOHw8HBsbOzo6Ein89SPl9OnJeaklD7lJNjpkxJzyjGnpcf+yxp2OiNbzCuyPBUc3FqVQAiPQjUFaMqRbUo1EtxRNWjLDg26KWUabIZhKhnZv418kTjmEsdcIiPDTmS4ZIZLZLjJkSsadio2qOzLFcOIq6gR7FoL0BoLGxlM2aMchEY3hcyBnUqlKrxmPxy6cnDErkeZW7ORW7MREfYBwx0csYcM++uQFmy4aguu+iWBi1s5d6pCNn3Y4CRdVQFa9bD1Ss/UFU7oYMSTjSBw/ZiVsno1Hrx7dS/FrkcZ17d/iqRjKXYvxe6l2b0U9/Pdqzq24PSsKApVzl6IGQ0BG+2umgI0+D677tIzRDmbVjAKplrdIFl9n33/u95ogo0m2eU3seU3sWiSjSbZd0k2mmCjyeK973vrj+cjVsW3d42pZLH6CdqYr3c3XtyJs7vx4u7ZZ3E3XtyJF3fixYDPgV3u14CqK6thj3qvjQy6/F6X3+saAT79gy7/oGvUe83ieKxVBbDPrhUNecbivOK0kRzYNpID20ZyYNtIDmwb6X+en23BoAUk9wAAAABJRU5ErkJggg==" alt="" />
UserDaoImpl类是IUserDao接口的具体实现类,对于接口的实现类命名方式,我习惯以"接口名(去除前缀I)+impl"形式或者"接口名+impl"形式来命名:IUserDao(接口)→UserDaoImpl(实现类)或者IUserDao(接口)→IUserDaoImpl(实现类),这也算是一些个人的编程习惯吧,平时看到的代码大多数都是以这两种形式中的一种来来命名接口的具体实现类的,反正就是要能够一眼看出接口对应的实现类是哪一个就可以了。
UserDaoImpl类的具体代码如下:
1 package me.gacl.dao.impl;
2
3 import java.text.SimpleDateFormat;
4 import org.dom4j.Document;
5 import org.dom4j.Element;
6 import me.gacl.dao.IUserDao;
7 import me.gacl.domain.User;
8 import me.gacl.util.XmlUtils;
9
10 /**
11 * IUserDao接口的实现类
12 * @author gacl
13 */
14 public class UserDaoImpl implements IUserDao {
15
16 @Override
17 public User find(String userName, String userPwd) {
18 try{
19 Document document = XmlUtils.getDocument();
20 //使用XPath表达式来操作XML节点
21 Element e = (Element) document.selectSingleNode("//user[@userName='"+userName+"' and @userPwd='"+userPwd+"']");
22 if(e==null){
23 return null;
24 }
25 User user = new User();
26 user.setId(e.attributeValue("id"));
27 user.setEmail(e.attributeValue("email"));
28 user.setUserPwd(e.attributeValue("userPwd"));
29 user.setUserName(e.attributeValue("userName"));
30 String birth = e.attributeValue("birthday");
31 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
32 user.setBirthday(sdf.parse(birth));
33
34 return user;
35
36 }catch (Exception e) {
37 throw new RuntimeException(e);
38 }
39 }
40
41 @SuppressWarnings("deprecation")
42 @Override
43 public void add(User user) {
44 try{
45 Document document = XmlUtils.getDocument();
46 Element root = document.getRootElement();
47 Element user_node = root.addElement("user"); //创建user结点,并挂到root
48 user_node.setAttributeValue("id", user.getId());
49 user_node.setAttributeValue("userName", user.getUserName());
50 user_node.setAttributeValue("userPwd", user.getUserPwd());
51 user_node.setAttributeValue("email", user.getEmail());
52
53 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
54 user_node.setAttributeValue("birthday", sdf.format(user.getBirthday()));
55
56 XmlUtils.write2Xml(document);
57
58 }catch (Exception e) {
59 throw new RuntimeException(e);
60 }
61 }
62
63 @Override
64 public User find(String userName) {
65 try{
66 Document document = XmlUtils.getDocument();
67 Element e = (Element) document.selectSingleNode("//user[@userName='"+userName+"']");
68 if(e==null){
69 return null;
70 }
71 User user = new User();
72 user.setId(e.attributeValue("id"));
73 user.setEmail(e.attributeValue("email"));
74 user.setUserPwd(e.attributeValue("userPwd"));
75 user.setUserName(e.attributeValue("userName"));
76 String birth = e.attributeValue("birthday");
77 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
78 user.setBirthday(sdf.parse(birth));
79
80 return user;
81
82 }catch (Exception e) {
83 throw new RuntimeException(e);
84 }
85 }
86
87 }
3.3、开发service层(service层对web层提供所有的业务服务)
在me.gacl.service包中创建IUserService接口类
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKIAAAApCAIAAAA552VXAAAIR0lEQVR4nO1a/U8b5x1//ov8GC1VoyhoUwz2ul4pyn+QX5aAWVirVXq0daoC25qIl4AAx2NUy06jStqEUtI14FDUoaQ5EjHK+IECTUMHzRLECYyLMT7bdxj8duagz364891zb46HbewGf/URel4+35fnPnfPPTYGKDtbn+7/6srPcKxP92cZs2Q5N1DoAkp2EFaS+VDY/mXe3fthfIF9f9TjGF4uIRu8P+oZX2B3937Ioa4a27/MX3wTuD8X8nLCNo9KyAZeTrg/F/rim0AOddXY/mXuHllhY3tsHIViJWQFNo7Y2F73yEoOddXY/mV2DC9v8SgYLSEH2OKRY3g5h7pqLCuZwwnERIzRUHnEbKqYQNUBOJiPyPOkFRCd85nyw4kilnkzgfzbEiY6LJNNP5XRc/Yo3p3osMjMYgJVB+BAPiJ/S1oB0fFtpvzNYpaZiyPftoTJS2X0RN/67K312Vtzn73XV1+DdycvlcnMYgJ1HsBPC18G4uJFIPPExERXV5dm0DG8zMaQNyxh4t2T67O3kltj7PzAswfX++pr8O7EuydlZjGB+hWA/yh8GYiNFVrm8fHxsrKy48ePa8Ydw8vBKPJsShhrOLk+e4udH2DnB549/ECUWe6ONZyUmWpQtYBoGyIrAAAA1A4hzxAEAAAAKpw0xgG6QaSbJdqcENjISXF8ToophTUORdUC2K8OOOkkUhR5S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口的具体代码如下:
1 package me.gacl.service;
2
3 import me.gacl.domain.User;
4 import me.gacl.exception.UserExistException;
5
6 public interface IUserService {
7
8 /**
9 * 提供注册服务
10 * @param user
11 * @throws UserExistException
12 */
13 void registerUser(User user) throws UserExistException;
14
15 /**
16 * 提供登录服务
17 * @param userName
18 * @param userPwd
19 * @return
20 */
21 User loginUser(String userName, String userPwd);
22 }
在me.gacl.service.impl包中创建UserServiceImpl类
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAALUAAAApCAIAAAD8lf/GAAAJNUlEQVR4nO1a608bVxY//0U/RpuqUZRopRjsdDOlKP9BvmwCpjjJbqXRtqsqsLtNxCNleZSyVJu92nSbNkkT0iZAKOoikgyNspRFKhtIGmeh2QQxCuDiGL/GNhjjMYbe/TDjmTtPIH5A2jn6Cd177nndMz9fXxsDtsQSY4GtLsCSbS0WPywxk5zxo7rkpVyFyqcwNNBMPgKziAIKsQV0lCVvm8qGH0NNtuHaX0o4e3gHOR1qsuWwytyJxY/NyfPzY/jUXnbo0rOxK8/Grri//PBSVTk5HT61N4dV5k7y2Mqtk4LzY2hoqK2tzdxz6N09z8aupBbucOOdT74+d6mqnJwOvbsnD9VmLxY/Nic6/BgcHNy7d++uXbvMPe9U73k2doUb7+TGO5/c/kTghzS9U23ED4YGCjGIAgAAmsGYoQEAgDxkMyrQPXmlVQohWrZgxZhiWP1QOq3U89MWwCIKaIahAYCiaUqZlkKssG7obrwj2XHdzhA1KMotID8EcpSXl6/Lj4F3dru//PDJ1+ee3P7kbkdTzaGD5HTgnd0GfkKLEZsZiltTtYlovnLrDC33hUWU1DwW0Rkn2YSh1c9D00ptBv0CBBYRT0TKKxgo6tcmNd6R0tG0M5oaZMeC8EMih9PpNOdHdclLZw/vuFRVLqDm0EEBkubs4R0Gn2jIZumN5ZeH3guO9NBM1SeBylh00LLB6PAiC1A910xoBX8MkprvSP+FoTtW1UCmzD8/SHKsyw+M8VdvvkJeSGsOHSSnX735ioHfBvhhcp034ofy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O7dLNbwo+ZCB73iWioer3uRGl9VWl9VWkd8bf+RGn9idKGqtclSwvjPjye4YeZzVXxg/o/sk43U3h+nLkxO+lf/d6H//vMwrbG9z486V89c2O2oPwYcIf67nNscM3giy8L2wVscK3vPnfrQWF/H5RKr924H2zvm97y389ZMEd73/SN+8FUeq2g/LDkxRWLH5aYyf8BrI0IjAezL38AAAAASUVORK5CYII=" alt="" />
UserServiceImpl类为IUserService接口的具体实现类,具体代码如下:
1 package me.gacl.service.impl;
2
3 import me.gacl.dao.IUserDao;
4 import me.gacl.dao.impl.UserDaoImpl;
5 import me.gacl.domain.User;
6 import me.gacl.exception.UserExistException;
7 import me.gacl.service.IUserService;
8
9 public class UserServiceImpl implements IUserService {
10
11 private IUserDao userDao = new UserDaoImpl();
12
13 @Override
14 public void registerUser(User user) throws UserExistException {
15 if (userDao.find(user.getUserName())!=null) {
16 //checked exception
17 //unchecked exception
18 //这里抛编译时异常的原因:是我想上一层程序处理这个异常,以给用户一个友好提示
19 throw new UserExistException("注册的用户名已存在!!!");
20 }
21 userDao.add(user);
22 }
23
24 @Override
25 public User loginUser(String userName, String userPwd) {
26 return userDao.find(userName, userPwd);
27 }
28
29 }
3.4、开发web层
3.4.1、 开发注册功能
1、在me.gacl.web.UI包下写一个RegisterUIServlet为用户提供注册界面
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMQAAABACAIAAADK5U/yAAAHzElEQVR4nO2b72sTZwDH77/YS3FjpVgm89fGbq74HyiDQAp7UTY49gMxBZ06C9Zou2xOdtBRBV1NxxIqjg2UnYorUaF2fSPoHC0NU2Nb26a5LjZtc2l0z15ccvfc8yN3MU/u0svz5RDv8jzPPc3zuee5XD4RAA8Powhed4DHP+Ew8TALh4mHWThMPMxSF5i6dr9Wj2ZZR5EESamphaQs1tqEn8IGpkR42+2v3jK2/sAmeDcR3sbkLKzjAkyKJIhy0lpDlJN6TUEQBF+xyAam24fbkonB2fGh2fGhe5dPD4aC8O7tw21MzsI6XsJE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aium/2MJlt4lavMym7yZxxN2Fy2QGHFnyiQG2/zMmoXEuBle50N5cz3mif5mp3wFHNG7OyifYz8QYcf/hjOtfkNgmXfhM54w31nMkzBxz4SwOvKgwfFzTUE3AXHXDgYw28qrB84N9QMLnqgAM/auBVhbkzXl+Y+NZsW71g4uEBAHCYeBiGw8TDLBwmHmbhMPEwy/9DRhmRqzVJSwAAAABJRU5ErkJggg==" alt="" />
RegisterUIServlet收到用户请求后,就跳到register.jsp
RegisterUIServlet的代码如下:
1 package me.gacl.web.UI;
2
3 import java.io.IOException;
4 import javax.servlet.ServletException;
5 import javax.servlet.http.HttpServlet;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
8 /**
9 * @author gacl
10 * 为用户提供注册的用户界面的Servlet
11 * RegisterUIServlet负责为用户输出注册界面
12 * 当用户访问RegisterUIServlet时,就跳转到WEB-INF/pages目录下的register.jsp页面
13 */
14 public class RegisterUIServlet extends HttpServlet {
15
16 public void doGet(HttpServletRequest request, HttpServletResponse response)
17 throws ServletException, IOException {
18 request.getRequestDispatcher("/WEB-INF/pages/register.jsp").forward(request, response);
19 }
20
21 public void doPost(HttpServletRequest request, HttpServletResponse response)
22 throws ServletException, IOException {
23 doGet(request, response);
24 }
25
26 }
2、在/WEB-INF/pages/目录下编写用户注册的jsp页面register.jsp
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAALwAAACYCAIAAADRFhTcAAANwklEQVR4nO2d728UxxnH50+IBC/aF5WqCNEXvACcMy/2VdT0RVDeRQlgUhQpqrZpG0Fw1caAgLiA4zoibKv8ICbhhzCHBXbr9OxtUnAJcmidiIAJCFy2DlhybZ992JYDyRnjTF/M7e7s7Mzuzu3e7d3e89Xz4nY9++zu3Eczezffe4xwOPW/nLp9Yrso+l9OzQ1/PNj02GTPDwabHnMdbWgKUnXHZmHb0BRUkNVAV5GiGXRbZwMmG7cNncPQFPO13ZJOxl4A1lVzn6Jp9NXwTokQUjTDvihDU5C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8SJtrC4FEmXJh8ajGusxLVHRNWdUSUC1Y4AGpC0qhWaC3orN+K+rppQtUJzvq+N9m6SuPG3X0XNTSl+R131NR//D8an7cuxrXhPAAAAAElFTkSuQmCC" alt="" />
凡是位于WEB-INF目录下的jsp页面是无法直接通过URL地址直接访问的,
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdEAAAD6CAIAAABxveqNAAAgAElEQVR4nO2d+VcbV5729X/0rz7xcZ/M9DszfifTme7TM3NmupvpGXoGxx2n8+IkTbZOQtqxA1m8QLwmtrHdxDh2jI0dvAovLGbzBgYvGLMahNgXsQuEQBIIIZF6f6jt3qpbpRJLgfHzOc/xwcWtW/feuvepb32rkCy36gZu1fXfqu2/WdNbXN1bVN1TVNVTVNVT+KSbV1FVT3F1T3GNo7im96Ygh6BqR3F1j6Aah6xqQUXVPbwKq3oKq/ifHUU1vcU1vcU1fcW1/cW1A6SKJNUMFNb0F1b3F1T35Vf13qh05D3uzqnoyn7Umf2g/dr99qvlbVfLW6+Wt14pk9Rypazlyr3mrFK7tdR++a7t4p1GWrZLd22XSpouldgvlzZfKm2+VGq/VGq/VNJ8UdSF0paLpS0XS1svlrZdLG2/WNr+7mf7yqqaCstrIWgFq6yq6c1Pv3nj02/Gp0KuSWgRZSmo7Cx43Hmjoj3vUVveg9acBy055c3Z5fbscvv1cvv1cnt2uT27vDnnfouoZknZYsnscn5LC63m7PLm62I918vt2eXN2fdbsu+35DxozXnQlvOwPfdRR+6jjtyKztyKrryKrryKrtyKrtyKrpxHXTmPOrIftmc/aL92v/VqecuVsmZric16t+Hi7fqLt+rPF9eeK645V1yTWVSbWVx7rrgms6gms6jmh6KaHwqrzxZUncmvPJ33mFdGXuXpG09O36jKyK8+W1hztqiW15mi2ozC2jOFtRmFdWeK6jKK6jOK6s8UNZwpbjx703b2ZtPZW/Y/bd5dWFppzb8HQStYhaWVsZ/sif1kDzx30T1315GMnUdO7zx86qvD6ckpJ5MOfp908ETSgeNJB47v2P/d9v3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OVI7g5VR5gNZvdOM87lizFbrueDCpNVWLC670y7DzNEEAQtpVSeS65zwQKk9awwQYU9iZIiyh0Kh5JE10MYjVBecWusn9Mkf6vTYKJVcs20HVef1Gowu3fanstvZ0aX2kFurKbnagf7xDhQbZYDc919IQgyW0rPpUxHueYVnks7jvIx0UjuDtraZGl6LpUWkFDuTh2dU99Ky+WJFhrzXI0Gs3un6bl8YVazw9zsz8Vz5VyQOqwOfwmBIMhcKTxX460AwT40PZeyEsLdNALVcJ5r6F54MT2XboBW77Q8ly+v/WBNu4NGcwu0dIoZrAGCILNEe65qidJxGTu3oLQqdW7BcJwbSVy2mLkFusFavdPwXM3EAjvIJcdc5xkaXayaPCJZ7KSdsld4LgQtM1Gey7A86vaW8kqyMGVhRh5JaTmLOkd80h5BPjf8M7QwnstscK5m71hxsVZigXqIx9jOj4bmu2IqaxZbSI/DSTvpsJqpEgiClkiU5+q4GOuVKdKdiaTE4AjpbnrvirHfiFLlNyLw3MSYsO+KhfFcZoN1eqd6l/mknWMlFsRWqeJfVSiq236+mHKINF900xw9CIKWRhH97e/z8Te789PROpaxQhAExSbGwHMXWnp/fgZBEATPhSAIMk/4bh4AADAPeC4AAJgHPBcAAMzj/wOfaVBItxKISAAAAABJRU5ErkJggg==" alt="" />
在开发中如果项目中有一些敏感web资源不想被外界直接访问,那么可以考虑将这些敏感的web资源放到WEB-INF目录下,这样就可以禁止外界直接通过URL来访问了。
register.jsp页面的代码如下:
1 <%@ page language="java" pageEncoding="UTF-8"%>
2 <!DOCTYPE HTML>
3 <html>
4 <head>
5 <title>用户注册</title>
6 </head>
7
8 <body style="text-align: center;">
9 <form action="${pageContext.request.contextPath}/servlet/RegisterServlet" method="post">
10 <table width="60%" border="1">
11 <tr>
12 <td>用户名</td>
13 <td>
14
15 <input type="text" name="userName">
16 </td>
17 </tr>
18 <tr>
19 <td>密码</td>
20 <td>
21 <input type="password" name="userPwd">
22 </td>
23 </tr>
24 <tr>
25 <td>确认密码</td>
26 <td>
27 <input type="password" name="confirmPwd">
28 </td>
29 </tr>
30 <tr>
31 <td>邮箱</td>
32 <td>
33 <input type="text" name="email">
34 </td>
35 </tr>
36 <tr>
37 <td>生日</td>
38 <td>
39 <input type="text" name="birthday">
40 </td>
41 </tr>
42 <tr>
43 <td>
44 <input type="reset" value="清空">
45 </td>
46 <td>
47 <input type="submit" value="注册">
48 </td>
49 </tr>
50 </table>
51 </form>
52 </body>
53 </html>
register.jsp中的<form action="${pageContext.request.contextPath}/servlet/RegisterServlet" method="post">指明表单提交后,交给RegisterServlet进行处理
3、在me.gacl.web.controller包下编写用于处理用户注册的RegisterServlet
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAALgAAABRCAIAAADuGvvaAAAIrklEQVR4nO2c/WsTZwDH77/Yj+LGSrFM5tvGbq74HyiDQAr7QTY49oKYgk6dBWu0XTcnO+iogq6mYwkVxwbKouJKVKhdfxF0jpaGqbGtbdNcF5u+XBrdsx8uuXvuebl7klwul9zz5RBzfd5y98lzz10+RAA8PAwR6j0AnsYIB4WHKRwUHqY4CUrn7tccbK1miUuCFK+qhaQsVtuE09HfVPXvjpyqQEmEt9356i196w9sgl8mwtucGqWj4aBUkqpAuXOkLZkYnB0fmh0fun/lzGAoCL+8c6TNqVE6Gu+DUkH79QMlkUj09fVZV04c3jI7PpR/cUt5EJu4cW4wFIRfJg5vcXq0joSDUknIoIyMjLS1tbW0tFhXvtW5ZXZ8SHkQUx7EJm6e10DRX97qpIESlwRRjsuiIAiCIMUBiEuCIAiCIMpJqIyA7QTYX0VZlowSyWKbxWbJTaGHMm40EJf0isZefCTaiTT2k84MXsvYA9WIS9pbMA0Prgn1hY3H3A4OiuXISYfVIgRQNEqCwaAtKNcPtN6/cmbixrmJm+fHIuFje/fAL68faKXUgwaqvRftrRkfpDhy8s1nAjqdGhrFsklZKlUyisQl9JigoMDdiqKoj6t02vCRaDyWGoGHA40Q6xTaYx4e9Pa1IvBbNvdl1Q7+H7uRlxMUFJ2Sjo4Oa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ihxMYs/A4ElWRYftnlEWk89R6mbMwsaX5vF4+wts6eezLrozIIm02bxOPyE2VOguOrMgmbRZvHUQqT1FCjcmfVuagIK35pycxgUHl+Gg8LDlP8BgULBxnZB0qEAAAAASUVORK5CYII=" alt="" />
RegisterServlet担任着以下几个职责:
1、接收客户端提交到服务端的表单数据。
2、校验表单数据的合法性,如果校验失败跳回到register.jsp,并回显错误信息。
3、如果校验通过,调用service层向数据库中注册用户。
为了方便RegisterServlet接收表单数据和校验表单数据,在此我设计一个用于校验注册表单数据RegisterFormbean,再写WebUtils工具类,封装客户端提交的表单数据到formbean中。
在me.gacl.web.formbean包下创建一个用于校验注册表单数据RegisterFormbean
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL8AAAAtCAIAAABwJi0ZAAAJgUlEQVR4nO1abU8bVxa+/yIfo03VKAraVQw23U4pyj/Il03ANE7SrTTa7aoK7G4T8b68hLJUmx0tVdImQEibACEoi5JmCMoSygcKJA3a0GyDGPHiYsBje4zBGI8x9O6HGc/cmbljO2aYAp2jR+jeO+c858yZx3cuBgDTtoWR9m8v/QbFwkh7+uGW7T8DP3cBlu1hs9RjWeaWlno2t34amOA+63PX90xb2Ov4rM89MMFtbv1kknq+/s73cDzgCcZXeWhhr8MTjD8cD3z9nc8k9TT1znCRLW4dBiIW9jy4dchFtpp6Z0xST33P9AoP/WsW9glWeFjfM22eekJRyIbxKMk7oHdpN4F2AbJzWwxMXS5w3UvtA0BKN2OTvjZCUXPVsxyF3lURg7W2obJfS2g+eRCdDtbaJM/dBNoFyI5tMTC1ucDVk8xntJEA79OGlp06aQZYNlk9wXW4uCpi6GIWM9i2MHZzYezm+N1P24oL0enQxSzJczeBPg3IW9tiYGpywemeZD633gf2RsbQslMnzQDB9Z1Rz+DgYGNjo1Y9XAR6QiIGPz66MHYztvKYe9Hx6tHVtuJCdDr48VHJczeBfg+QX22LgflbLnjvbjKfr86BnE8YQ8tOnTQDcJEdUM/AwEBWVtbhw4e16vGvQfe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gHr8fn+a557LF99eDPIjbu7D9uEP24cF9SxyscUgv8Tx/7iYjnrQ/Vi1E2m3J/ybi6JVtDrqlDlTqUf75sK3PNO9B1uV6oiURD1Sy9DXOyZWiCBJSXN6bgkz9XeuxgvvzPv5ETeX/+dOQToePz/v5+cD/Lw/9vcL7+jEYR6e4lyh2lXlRfypWX4PqE6QuufElOpRsGpOzahPavUADI9uVeJ9kmSyvUerHnws1IhEz000U7/vufSXPDfLu31834Snb8Lj9vFuHz/n490s7/ZF6/+at81iMIZ/E/1SzejvAEz9rrmmJG/WG53x8rPe6Kz4Mzrrjc54ozPeaG2JIephKEJxrrbEI5nhf60xVT3Vxe+Wn8+vKM6vKM4vR35WnM+vOJ9fXfyuMWmQTd6SjmjiG9HgLx+t/9CwLHOz1GNZ5mapx7LMzVKPZZmbpR7LMrf/A/+GYfI+o8MzAAAAAElFTkSuQmCC" alt="" />
RegisterFormbean代码如下:
1 package me.gacl.web.formbean;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;
7
8 /**
9 * 封装的用户注册表单bean,用来接收register.jsp中的表单输入项的值
10 * RegisterFormBean中的属性与register.jsp中的表单输入项的name一一对应
11 * RegisterFormBean的职责除了负责接收register.jsp中的表单输入项的值之外还担任着校验表单输入项的值的合法性
12 * @author gacl
13 *
14 */
15 public class RegisterFormBean {
16
17 //RegisterFormBean中的属性与register.jsp中的表单输入项的name一一对应
18 //<input type="text" name="userName"/>
19 private String userName;
20 //<input type="password" name="userPwd"/>
21 private String userPwd;
22 //<input type="password" name="confirmPwd"/>
23 private String confirmPwd;
24 //<input type="text" name="email"/>
25 private String email;
26 //<input type="text" name="birthday"/>
27 private String birthday;
28
29
30 /**
31 * 存储校验不通过时给用户的错误提示信息
32 */
33 private Map<String, String> errors = new HashMap<String, String>();
34
35 public Map<String, String> getErrors() {
36 return errors;
37 }
38
39 public void setErrors(Map<String, String> errors) {
40 this.errors = errors;
41 }
42
43 /*
44 * validate方法负责校验表单输入项
45 * 表单输入项校验规则:
46 * private String userName; 用户名不能为空,并且要是3-8的字母 abcdABcd
47 * private String userPwd; 密码不能为空,并且要是3-8的数字
48 * private String confirmPwd; 两次密码要一致
49 * private String email; 可以为空,不为空要是一个合法的邮箱
50 * private String birthday; 可以为空,不为空时,要是一个合法的日期
51 */
52 public boolean validate() {
53
54 boolean isOk = true;
55
56 if (this.userName == null || this.userName.trim().equals("")) {
57 isOk = false;
58 errors.put("userName", "用户名不能为空!!");
59 } else {
60 if (!this.userName.matches("[a-zA-Z]{3,8}")) {
61 isOk = false;
62 errors.put("userName", "用户名必须是3-8位的字母!!");
63 }
64 }
65
66 if (this.userPwd == null || this.userPwd.trim().equals("")) {
67 isOk = false;
68 errors.put("userPwd", "密码不能为空!!");
69 } else {
70 if (!this.userPwd.matches("\\d{3,8}")) {
71 isOk = false;
72 errors.put("userPwd", "密码必须是3-8位的数字!!");
73 }
74 }
75
76 // private String password2; 两次密码要一致
77 if (this.confirmPwd != null) {
78 if (!this.confirmPwd.equals(this.userPwd)) {
79 isOk = false;
80 errors.put("confirmPwd", "两次密码不一致!!");
81 }
82 }
83
84 // private String email; 可以为空,不为空要是一个合法的邮箱
85 if (this.email != null && !this.email.trim().equals("")) {
86 if (!this.email.matches("\\w+@\\w+(\\.\\w+)+")) {
87 isOk = false;
88 errors.put("email", "邮箱不是一个合法邮箱!!");
89 }
90 }
91
92 // private String birthday; 可以为空,不为空时,要是一个合法的日期
93 if (this.birthday != null && !this.birthday.trim().equals("")) {
94 try {
95 DateLocaleConverter conver = new DateLocaleConverter();
96 conver.convert(this.birthday);
97 } catch (Exception e) {
98 isOk = false;
99 errors.put("birthday", "生日必须要是一个日期!!");
100 }
101 }
102
103 return isOk;
104 }
105
106 public String getUserName() {
107 return userName;
108 }
109
110 public void setUserName(String userName) {
111 this.userName = userName;
112 }
113
114 public String getUserPwd() {
115 return userPwd;
116 }
117
118 public void setUserPwd(String userPwd) {
119 this.userPwd = userPwd;
120 }
121
122 public String getConfirmPwd() {
123 return confirmPwd;
124 }
125
126 public void setConfirmPwd(String confirmPwd) {
127 this.confirmPwd = confirmPwd;
128 }
129
130 public String getEmail() {
131 return email;
132 }
133
134 public void setEmail(String email) {
135 this.email = email;
136 }
137
138 public String getBirthday() {
139 return birthday;
140 }
141
142 public void setBirthday(String birthday) {
143 this.birthday = birthday;
144 }
145 }
在me.gacl.util包下创建一个WebUtils工具类,该工具类的功能就是封装客户端提交的表单数据到formbean中
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAAAqCAIAAAA8ty7CAAAIW0lEQVR4nO2a/U9b1xnHn/+iP0ZL1SgKmhSD7S63FOU/yE8JOOCErNLR2qkKbGsj3kIAl3lUy45G17QNJaRLgBCUIZJcEmWUIo3FJI0ZNFsirsC4GOO3axsb29cYevbDvb4+12+Q4AJO/Ogr65xzv89zju6He3xsA6QQ+Raw2wsoxAtHgVn+RYFZ/kUumdWWvpHDaj9bsAgQ+0IZHGaAwdxL5f4MsS1mY62q8fpfyuo8vo/ujrWqcrXKnMbrzWz8XBE31r00eXVp8qr55qfdNRV0d/xcUa5WmdPY4n3nMJPq29vMxsbGjEZj9uSxjw4tTV6Nrjzgp3uf3bvUXVNBd8c+OpTr1eYkXlFmo6OjRUVFBw4cyJ78oPbQ0uRVfrqXn+59dv8LkZncfVCbiRmLgMEsZgAAALGEsAgAAKQNKO6BlEGScpXBGCUcnFRTKpu+VMp9p+lI7UQKMJhLGPYqMxFYRUXFpsxGPjxovvnps3uXnt3/4mFPa92xo3R35MODGfJYJKMQb454HxS3RsFBeZ9YBIp7HPdyGMWTEhYWJVPfCjPl6B5nJgPT6XTZmdWWvtF5fF93TYWoumNHRckjncf3ZThJ0kjStam/8jSPGp2R0k1+0pLMUsIrxIwGtikzQsit996iDx11x47S3VvvvZUhbwvM0m2IabLprvKRY14TZkaj8QAV7e3t2ZNvVL+Z5Qxyo/rNDHmbMVPsfoRFiCVJB+50eyNVicMMvTfG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AyAAAAAElFTkSuQmCC" alt="" />
1 package me.gacl.util;
2
3 import java.util.Enumeration;
4 import java.util.UUID;
5 import javax.servlet.http.HttpServletRequest;
6 import org.apache.commons.beanutils.BeanUtils;
7
8 /**
9 * @author gacl
10 * 把request对象中的请求参数封装到bean中
11 */
12 public class WebUtils {
13
14 /**
15 * 将request对象转换成T对象
16 * @param request
17 * @param clazz
18 * @return
19 */
20 public static <T> T request2Bean(HttpServletRequest request,Class<T> clazz){
21 try{
22 T bean = clazz.newInstance();
23 Enumeration<String> e = request.getParameterNames();
24 while(e.hasMoreElements()){
25 String name = (String) e.nextElement();
26 String value = request.getParameter(name);
27 BeanUtils.setProperty(bean, name, value);
28 }
29 return bean;
30 }catch (Exception e) {
31 throw new RuntimeException(e);
32 }
33 }
34
35 /**
36 * 生成UUID
37 * @return
38 */
39 public static String makeId(){
40 return UUID.randomUUID().toString();
41 }
42
43 }
最后看一下负责处理用户注册的RegisterServlet完整代码:
1 package me.gacl.web.controller;
2
3 import java.io.IOException;
4 import java.util.Date;
5 import javax.servlet.ServletException;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import org.apache.commons.beanutils.BeanUtils;
10 import org.apache.commons.beanutils.ConvertUtils;
11 import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;
12 import me.gacl.domain.User;
13 import me.gacl.exception.UserExistException;
14 import me.gacl.service.IUserService;
15 import me.gacl.service.impl.UserServiceImpl;
16 import me.gacl.util.WebUtils;
17 import me.gacl.web.formbean.RegisterFormBean;
18 /**
19 * 处理用户注册的Servlet
20 * @author gacl
21 *
22 */
23 public class RegisterServlet extends HttpServlet {
24
25 public void doGet(HttpServletRequest request, HttpServletResponse response)
26 throws ServletException, IOException {
27 //将客户端提交的表单数据封装到RegisterFormBean对象中
28 RegisterFormBean formbean = WebUtils.request2Bean(request,RegisterFormBean.class);
29 //校验用户注册填写的表单数据
30 if (formbean.validate() == false) {//如果校验失败
31 //将封装了用户填写的表单数据的formbean对象发送回register.jsp页面的form表单中进行显示
32 request.setAttribute("formbean", formbean);
33 //校验失败就说明是用户填写的表单数据有问题,那么就跳转回register.jsp
34 request.getRequestDispatcher("/WEB-INF/pages/register.jsp").forward(request, response);
35 return;
36 }
37
38 User user = new User();
39 try {
40 // 注册字符串到日期的转换器
41 ConvertUtils.register(new DateLocaleConverter(), Date.class);
42 BeanUtils.copyProperties(user, formbean);//把表单的数据填充到javabean中
43 user.setId(WebUtils.makeId());//设置用户的Id属性
44 IUserService service = new UserServiceImpl();
45 //调用service层提供的注册用户服务实现用户注册
46 service.registerUser(user);
47 String message = String.format(
48 "注册成功!!3秒后为您自动跳到登录页面!!<meta http-equiv='refresh' content='3;url=%s'/>",
49 request.getContextPath()+"/servlet/LoginUIServlet");
50 request.setAttribute("message",message);
51 request.getRequestDispatcher("/message.jsp").forward(request,response);
52
53 } catch (UserExistException e) {
54 formbean.getErrors().put("userName", "注册用户已存在!!");
55 request.setAttribute("formbean", formbean);
56 request.getRequestDispatcher("/WEB-INF/pages/register.jsp").forward(request, response);
57 } catch (Exception e) {
58 e.printStackTrace(); // 在后台记录异常
59 request.setAttribute("message", "对不起,注册失败!!");
60 request.getRequestDispatcher("/message.jsp").forward(request,response);
61 }
62 }
63
64 public void doPost(HttpServletRequest request, HttpServletResponse response)
65 throws ServletException, IOException {
66 doGet(request, response);
67 }
68
69 }
用户注册时如果填写的表单数据校验不通过,那么服务器端就将一个存储了错误提示消息和表单数据的formbean对象存储到request对象中,然后发送回register.jsp页面,因此我们需要在register.jsp页面中取出request对象中formbean对象,然后将用户填写的表单数据重新回显到对应的表单项上面,将出错时的提示消息也显示到form表单上面,让用户知道是哪些数据填写不合法!
修改register.jsp页面,代码如下:
1 <%@ page language="java" pageEncoding="UTF-8"%>
2 <!DOCTYPE HTML>
3 <html>
4 <head>
5 <title>用户注册</title>
6 </head>
7
8 <body style="text-align: center;">
9 <form action="${pageContext.request.contextPath}/servlet/RegisterServlet" method="post">
10 <table width="60%" border="1">
11 <tr>
12 <td>用户名</td>
13 <td>
14 <%--使用EL表达式${}提取存储在request对象中的formbean对象中封装的表单数据(formbean.userName)以及错误提示消息(formbean.errors.userName)--%>
15 <input type="text" name="userName" value="${formbean.userName}">${formbean.errors.userName}
16 </td>
17 </tr>
18 <tr>
19 <td>密码</td>
20 <td>
21 <input type="password" name="userPwd" value="${formbean.userPwd}">${formbean.errors.userPwd}
22 </td>
23 </tr>
24 <tr>
25 <td>确认密码</td>
26 <td>
27 <input type="password" name="confirmPwd" value="${formbean.confirmPwd}">${formbean.errors.confirmPwd}
28 </td>
29 </tr>
30 <tr>
31 <td>邮箱</td>
32 <td>
33 <input type="text" name="email" value="${formbean.email}">${formbean.errors.email}
34 </td>
35 </tr>
36 <tr>
37 <td>生日</td>
38 <td>
39 <input type="text" name="birthday" value="${formbean.birthday}">${formbean.errors.birthday}
40 </td>
41 </tr>
42 <tr>
43 <td>
44 <input type="reset" value="清空">
45 </td>
46 <td>
47 <input type="submit" value="注册">
48 </td>
49 </tr>
50 </table>
51 </form>
52 </body>
53 </html>
到此,用户注册功能就算是开发完成了!
下面测试一下开发好的用户注册功能:
输入URL地址:http://localhost:8080/webmvcframework/servlet/RegisterUIServlet访问register.jsp页面,运行效果如下:
如果输入的表单项不符合校验规则,那么是无法进行注册的,运行效果如下:
3.4.2、 开发登录功能
1、在me.gacl.web.UI包下写一个LoginUIServlet为用户提供登录界面
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAABACAIAAADDDu+IAAAK50lEQVR4nO1a+28TVxa+/wU/ona1CIEW4cTOamdZxH9AtdqQmGJgd6XRPlQ1kWhpSCAvk2bptjsSiLZAQtiSkIaoG5EyAbFpoNpAAiUslC1WRnmYOCF+jHHsOLFxwtkf5nU9DztmPI5jz6ejaObOueecmfv53puZD4EJEzqA1rsAExsbJoFM6ELGBFpZfT34hD0z4Hb2Tpimx84MuAefsCurr40Y15whYwJ9+4Pv+ljA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7qqlbtX2tGGmc8QAFrqBUwUhOtjSxpojEKqerF0hNIiqlUvK5NpFxkGmoFjNREayCLmmhsAVcVFKdfwii58FSDoNoa5+LSUCuwDv+F6ddEy2XPCpWyqhpYdROtfDkjaZDVY6r8JItIQ61Art8DrZsmGgpLFp0RjPzXPtdvonOoiYYClkVnBEO/3OSaQDnVREMhyqIzQtY11ArkmkCmJrrAYOqBTOiCSSATumASyIQu/B8cc1gIDiqxpwAAAABJRU5ErkJggg==" alt="" />
LoginUIServlet收到用户请求后,就跳到login.jsp
LoginUIServlet的代码如下:
1 package me.gacl.web.UI;
2
3 import java.io.IOException;
4
5 import javax.servlet.ServletException;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
10 /**
11 * @author gacl
12 * LoginUIServlet负责为用户输出登陆界面
13 * 当用户访问LoginUIServlet时,就跳转到WEB-INF/pages目录下的login.jsp页面
14 */
15 public class LoginUIServlet extends HttpServlet {
16
17 public void doGet(HttpServletRequest request, HttpServletResponse response)
18 throws ServletException, IOException {
19
20 request.getRequestDispatcher("/WEB-INF/pages/login.jsp").forward(request, response);
21 }
22
23 public void doPost(HttpServletRequest request, HttpServletResponse response)
24 throws ServletException, IOException {
25 doGet(request, response);
26 }
27
28 }
2、在/WEB-INF/pages/目录下编写用户登录的jsp页面login.jsp
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAALUAAACQCAIAAADBUL17AAAKW0lEQVR4nO2dz28bZRrH/T/0xAFpVaFy6CFSDz3MqVq4cOUAjfaAVKFBYqumDUJ0hVg2QileUNUBwW62gYYqwVSQ7Ba5sbRLo4JCtBxWNPwQDTXQVoo2IU2rCrVi0rQaDmPPvO87z/vM2DNjv+P5fvQe7On4tTvvx+879nz9pOIBoKfS7xcAjAZ+AA74ATgK7UfTsSp2o9+vYqDJ0o/F1/cGLfmjGnZFHOSmY1Usp6m5K6Pzo+lYlRDtw0E8mfkxd/Ah5i5Hw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+qp3R+lCJ/mh2l8wN0BPwAHPADcMAPwAE/AEex/bjQqJKt369rcPgNRCsg41GlFisAAAAASUVORK5CYII=" alt="" />
login.jsp页面的代码如下:
1 <%@ page language="java" pageEncoding="UTF-8"%>
2 <!DOCTYPE HTML>
3 <html>
4 <head>
5 <title>用户登陆</title>
6 </head>
7
8 <body>
9 <form action="${pageContext.request.contextPath }/servlet/LoginServlet" method="post">
10 用户名:<input type="text" name="username"><br/>
11 密码:<input type="password" name="password"><br/>
12 <input type="submit" value="登陆">
13 </form>
14 </body>
15 </html>
login.jsp中的<form action="${pageContext.request.contextPath}/servlet/LoginServlet" method="post">指明表单提交后,交给LoginServlet进行处理。
3、在me.gacl.web.controller包下编写用于处理用户登录的LoginServlet
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAABQCAIAAADELT0uAAAIvElEQVR4nO2c/WsTZwDH77/Yj+LGSrFM5tvGbq74HyiDQAr7QTY49oKYgk6dBWu0XTcnO+iogq6mYykVxwbKouJKVKhdfxF0jpaGqbGtbdOki01fLo3u2Q/X3D33vNxL77nm7vJ8OaS5Pm9398lzTy4fKwAeHtcRaj0AnjCEY8TDIJ5g1Lr7NS+aZZ2UJEgpVy1kZNFtE6yjHZT7o3MQNhil49vufPWWtnVHNsEv0/FtTHphHY4Rs7DB6M6Rpky6d2qkb2qk7/6VM72xKPzyzpEmJr2wjv8xWkf7fsUonU53dXVZlDm8ZWqkr/ziVuFB/+iNc72xKPwyfXgLo9GyDceIWSwwGhwcbGpqamhoMC92q3XL1Ehf4UF/4UH/6M3zKkbay1utNIxSkiDKKVkUBEEQpBQAKUkQBEEQRDkDlRGwnQD7rSjLkl4is9bmWrPkptATndIbSElaRX0vPhL1Muv7SdcNr6XvgWqkJPUQDMODa0J9YeMxtoNjZDpy0ml1GjOMVIai0aglRtcPNN6/cmb0xrnRm+eHE/Fje/fAL68faKTUgw5DPVL1wPU3YQpBw3idoIutgrNWNiNL1Up6kZSEnjEUI7hbURS1cV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RUz1rUO+CduBdbEQcFIxZe3tb/01j+hvcvihdx4J2CFxsCCSilWaNkd4m/veOHYjSegd1J2iHwcWG7v9Eqdn6piaj2isFU5pnXfeCdoBdbFS3Rh1lspFMXGLjz3xg+dqOZ13ngnadudgg+Do2Hh88BAi9iw1CpmPj8cFD7HpwsUFYdGw8vhG0uYvNwyDcN+JhEI4RD4NwjHgY5H+HzT66jOImEQAAAABJRU5ErkJggg==" alt="" />
LoginServlet的代码如下:
1 package me.gacl.web.controller;
2
3 import java.io.IOException;
4
5 import javax.servlet.ServletException;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
10 import me.gacl.domain.User;
11 import me.gacl.service.IUserService;
12 import me.gacl.service.impl.UserServiceImpl;
13
14 /**
15 * 处理用户登录的servlet
16 * @author gacl
17 *
18 */
19 public class LoginServlet extends HttpServlet {
20
21 public void doGet(HttpServletRequest request, HttpServletResponse response)
22 throws ServletException, IOException {
23
24 //获取用户填写的登录用户名
25 String username = request.getParameter("username");
26 //获取用户填写的登录密码
27 String password = request.getParameter("password");
28
29 IUserService service = new UserServiceImpl();
30 //用户登录
31 User user = service.loginUser(username, password);
32 if(user==null){
33 String message = String.format(
34 "对不起,用户名或密码有误!!请重新登录!2秒后为您自动跳到登录页面!!<meta http-equiv='refresh' content='2;url=%s'",
35 request.getContextPath()+"/servlet/LoginUIServlet");
36 request.setAttribute("message",message);
37 request.getRequestDispatcher("/message.jsp").forward(request, response);
38 return;
39 }
40 //登录成功后,就将用户存储到session中
41 request.getSession().setAttribute("user", user);
42 String message = String.format(
43 "恭喜:%s,登陆成功!本页将在3秒后跳到首页!!<meta http-equiv='refresh' content='3;url=%s'",
44 user.getUserName(),
45 request.getContextPath()+"/index.jsp");
46 request.setAttribute("message",message);
47 request.getRequestDispatcher("/message.jsp").forward(request, response);
48 }
49
50 public void doPost(HttpServletRequest request, HttpServletResponse response)
51 throws ServletException, IOException {
52 doGet(request, response);
53 }
54
55 }
到此,用户登录的功能就算是开发完成了。
下面测试一下开发好的用户登录功能,输入URL地址:http://localhost:8080/webmvcframework/servlet/LoginUIServlet访问login.jsp页面,输入正确的用户名和密码进行登录,运行效果如下:
如果输入的用户名和密码错误,那么就无法登录成功,运行效果如下:
3.4.3、 开发注销功能
在me.gacl.web.controller包下编写用于处理用户注销的LogoutServlet
LogoutServlet的代码如下:
1 package me.gacl.web.controller;
2
3 import java.io.IOException;
4 import java.text.MessageFormat;
5
6 import javax.servlet.ServletException;
7 import javax.servlet.http.HttpServlet;
8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse;
10
11 public class LogoutServlet extends HttpServlet {
12
13 public void doGet(HttpServletRequest request, HttpServletResponse response)
14 throws ServletException, IOException {
15 //移除存储在session中的user对象,实现注销功能
16 request.getSession().removeAttribute("user");
17 //由于字符串中包含有单引号,在这种情况下使用MessageFormat.format方法拼接字符串时就会有问题
18 //MessageFormat.format方法只是把字符串中的单引号去掉,不会将内容填充到指定的占位符中
19 String tempStr1 = MessageFormat.format(
20 "注销成功!!3秒后为您自动跳到登录页面!!<meta http-equiv='refresh' content='3;url={0}'/>",
21 request.getContextPath()+"/servlet/LoginUIServlet");
22 System.out.println(tempStr1);//输出结果:注销成功!!3秒后为您自动跳到登录页面!!<meta http-equiv=refresh content=3;url={0}/>
23 System.out.println("---------------------------------------------------------");
24 /**
25 * 要想解决"如果要拼接的字符串包含有单引号,那么MessageFormat.format方法就只是把字符串中的单引号去掉,不会将内容填充到指定的占位符中"这个问题,
26 * 那么可以需要使用单引号引起来的字符串中使用2个单引号引起来,例如:"<meta http-equiv=''refresh'' content=''3;url={0}''/>"
27 * 这样MessageFormat.format("<meta http-equiv=''refresh'' content=''3;url={0}''/>","index.jsp")就可以正常返回
28 * <meta http-equiv=''refresh'' content=''3;url=index.jsp'/>
29 */
30 String tempStr2 = MessageFormat.format(
31 "注销成功!!3秒后为您自动跳到登录页面!!<meta http-equiv=''refresh'' content=''3;url={0}''/>",
32 request.getContextPath()+"/servlet/LoginUIServlet");
33 /**
34 * 输出结果:
35 * 注销成功!!3秒后为您自动跳到登录页面!!
36 * <meta http-equiv='refresh' content='3;url=/webmvcframework/servlet/LoginUIServlet'/>
37 */
38 System.out.println(tempStr2);
39
40 String message = String.format(
41 "注销成功!!3秒后为您自动跳到登录页面!!<meta http-equiv='refresh' content='3;url=%s'/>",
42 request.getContextPath()+"/servlet/LoginUIServlet");
43 request.setAttribute("message",message);
44 request.getRequestDispatcher("/message.jsp").forward(request, response);
45 }
46
47 public void doPost(HttpServletRequest request, HttpServletResponse response)
48 throws ServletException, IOException {
49 doGet(request, response);
50 }
51
52 }
用户登录成功后,会将登录的用户信息存储在session中,所以我们要将存储在session中的user删除掉,这样就可以实现用户注销了。
用户登录成功后就会跳转到index.jsp页面,在index.jsp页面中放一个【退出登陆】按钮,当点击【退出登陆】按钮时,就访问LogoutServlet,将用户注销。
index.jsp的代码如下:
1 <%@ page language="java" pageEncoding="UTF-8"%>
2 <%--为了避免在jsp页面中出现java代码,这里引入jstl标签库,利用jstl标签库提供的标签来做一些逻辑判断处理 --%>
3 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4 <!DOCTYPE HTML>
5 <html>
6 <head>
7 <title>首页</title>
8 <script type="text/javascript">
9 function doLogout(){
10 //访问LogoutServlet注销当前登录的用户
11 window.location.href="${pageContext.request.contextPath}/servlet/LogoutServlet";
12 }
13 </script>
14 </head>
15
16 <body>
17 <h1>孤傲苍狼的网站</h1>
18 <hr/>
19 <c:if test="${user==null}">
20 <a href="${pageContext.request.contextPath}/servlet/RegisterUIServlet" target="_blank">注册</a>
21 <a href="${pageContext.request.contextPath}/servlet/LoginUIServlet">登陆</a>
22 </c:if>
23 <c:if test="${user!=null}">
24 欢迎您:${user.userName}
25 <input type="button" value="退出登陆" onclick="doLogout()">
26 </c:if>
27 <hr/>
28 </body>
29 </html>
测试开发好的注销功能,效果如下:
到此,所有的功能都开发完成了,测试也通过了。
四、开发总结
通过这个小例子,可以了解到mvc分层架构的项目搭建,在平时的项目开发中,也都是按照如下的顺序来进行开发的:
1、搭建开发环境
1.1 创建web项目
1.2 导入项目所需的开发包
1.3 创建程序的包名,在java中是以包来体现项目的分层架构的
2、开发domain
把一张要操作的表当成一个VO类(VO类只定义属性以及属性对应的get和set方法,没有涉及到具体业务的操作方法),VO表示的是值对象,通俗地说,就是把表中的每一条记录当成一个对象,表中的每一个字段就作为这个对象的属性。每往表中插入一条记录,就相当于是把一个VO类的实例对象插入到数据表中,对数据表进行操作时,都是直接把一个VO类的对象写入到表中,一个VO类对象就是一条记录。每一个VO对象可以表示一张表中的一行记录,VO类的名称要和表的名称一致或者对应。
3、开发dao
3.1 DAO操作接口:每一个DAO操作接口规定了,一张表在一个项目中的具体操作方法,此接口的名称最好按照如下格式编写:“I表名称Dao”。
├DAO接口里面的所有方法按照以下的命名编写:
├更新数据库:doXxx()
├查询数据库:findXxx()或getXxx()
3.2 DAO操作接口的实现类:实现类中完成具体的增删改查操作
├此实现类完成的只是数据库中最核心的操作,并没有专门处理数据库的打开和关闭,因为这些操作与具体的业务操作无关。
4、开发service(service 对web层提供所有的业务服务)
5、开发web层
咸鱼入门到放弃11--Servlet+JSP+JavaBean开发模式的更多相关文章
- javaweb学习总结(二十二)——基于Servlet+JSP+JavaBean开发模式的用户登录注册
一.Servlet+JSP+JavaBean开发模式(MVC)介绍 Servlet+JSP+JavaBean模式(MVC)适合开发复杂的web应用,在这种模式下,servlet负责处理用户请求,jsp ...
- 咸鱼入门到放弃10--javaweb的两种开发模式
(本篇是之前方法的综合使用,新东西不多,其中也涉及三层架构的问题.此处直接引用了大佬blog:https://www.cnblogs.com/xdp-gacl/p/3908610.html) SUN公 ...
- JavaWeb学习 (二十一)————基于Servlet+JSP+JavaBean开发模式的用户登录注册
一.Servlet+JSP+JavaBean开发模式(MVC)介绍 Servlet+JSP+JavaBean模式(MVC)适合开发复杂的web应用,在这种模式下,servlet负责处理用户请求,jsp ...
- 基于Servlet+JSP+JavaBean开发模式的用户登录注册
http://www.cnblogs.com/xdp-gacl/p/3902537.html 一.Servlet+JSP+JavaBean开发模式(MVC)介绍 Servlet+JSP+JavaBea ...
- javaweb(二十二)——基于Servlet+JSP+JavaBean开发模式的用户登录注册
一.Servlet+JSP+JavaBean开发模式(MVC)介绍 Servlet+JSP+JavaBean模式(MVC)适合开发复杂的web应用,在这种模式下,servlet负责处理用户请求,jsp ...
- Servlet+JSP+JavaBean开发模式(MVC)介绍
好伤心...写登陆注册之前看见一篇很好的博文,没有收藏,然后找不到了. 前几天在知乎上看见一个问题,什么时候感觉最无力. 前两天一直想回答:尝试过google到的所有solve case,结果bug依 ...
- javaweb开发3.基于Servlet+JSP+JavaBean开发模式的用户登录注册
转载孤傲苍狼博客http://www.cnblogs.com/xdp-gacl/p/3902537.html 1.层次比较分明的项目结构图
- JavaWeb -- Servlet+JSP+JavaBean(MVC)模式
Servlet+JSP+JavaBean(MVC)模式适合开发复杂的web应用,在这种模式下,servlet负责处理用户请求,jsp负责数据显示,javabean负责封装数据. Servlet+JSP ...
- jsp javabean开发模式
JSP&&JavaBean开发模式 在jsp+javabean架构中,jsp负责控制逻辑,表现逻辑,业务对象的调用 jsp+javaBean模式适合开发业务逻辑不复杂的web应用,这种 ...
随机推荐
- 20175209 《Java程序设计》第九周学习总结
20175209 <Java程序设计>第九周学习总结 一.教材知识点总结 有关数据库下载中存在可能出现的问题已经在博客<数据库安装和使用过程中出现的一些问题>给出了相应的解决办 ...
- Maven 学习总结 (六) 之 版本
版本管理 版本管理是指项目整体版本的演变过程管理.版本控制是指借助版本控制工具(如Subversion)追踪代码的每一个变更. 为了方便团队合作,项目开发过程中,大家应该使用快照版本,快照版本机制促进 ...
- CMake快速入门
参考: https://www.hahack.com/codes/cmake/ 1. 单目标文件 main.c #include <stdio.h> #include <stdlib ...
- JavaScript 修改 CSS 伪类属性
背景 有时候我们希望通过JS代码控制伪类属性, 确苦于对策 实际上可通过向document.head中添加style子元素来实现 演示 function css(style_text) { var s ...
- python中opencv的安装
1.得到opencv的安装包: 2.把安装包中的cv.py, cv2.pd放到一个文件夹中,并把这个文件夹放到D:\Anaconda2\Lib\site-packages中: 3.添加新的变量,变量名 ...
- R语言数据集的技术
特征值选择技术要点 特征值选择技术要点(特征值分解) 作者:王立敏 文章来源:xiahouzuoxin 一.特征值分解 1.特征值分解 线性代数中,特征分解(Eigendecomposition),又 ...
- 第31月第19天 NV12
1. //设置CIContext,并从CIImage -> CGImage -> UIImage CIContext *context = [CIContext contextWithOp ...
- spring kafka生产、消费消息
参考网址: https://blog.csdn.net/lansetiankong12/article/details/54946641 1.新建Maven项目-KafkaMaven ->点击n ...
- CentOS7中启动Chrome报错ERROR:zygote_host_impl_linux.cc
网上查的解决了问题 1. 需要安装libexif 说明我已经安装了libexif 2. 从安全角度考虑,Chrome不应在root环境下运行,如果某些原因必须以root身份运行Chrome,可以运行下 ...
- django-auth组件
auth组件 一.auth模块简介 auth模块是django自带的用户认证模块,包含了身份验证和权限管理两部分. 身份验证用于核实某个用户是否合法,权限管理用于决定一个合法用户有哪些权限 默认情况下 ...