实现效果
后端层
先写好pojo实体 User
写interface接口 UserDao
(insertUser 在之后的控制层、xml中都要用到,名字需要统一,不要弄混了)
实现接口 UserDaoImpl
(连接数据库会话层)
控制层UserController
(RequestMapping 的 register在jsp页面会用到,return 后返回的是jsp页面,要看清楚自己spring-mvc.xml中设置的前缀和后缀,不然跳转时页面可能会出错)
Mybatis配置文件 UsersMapper.xml(注意自己项目中的namespace和type路径,不要忘记在mybatis-config.xml中添加<mapper resource...>)
前端层
register.jsp(form action后对应的是UserController中的RequestMapping,我这里是因为跳转时找不到路径,所以把自己前面的路径也加上去了) 密码的type应该为password,为了显示效果所以用了text,大家记得用password
success.jsp
最后提交成功