春季MVC Web应用程序如何确认电子邮件地址 [英] How to confirm email addrees in spring MVC web application

查看:120
本文介绍了春季MVC Web应用程序如何确认电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向用户注册电子邮件地址。但是我想发送给用户一个确认链接,如果他们点击,那么他们的电子邮件地址得到确认

 我正在使用java spring MVC hibernate mysql 


解决方案

其他工具可以使用java邮件打包从您的应用程序发送电子邮件。以下是API文档的链接 Java Mail API



所以情况可能如下所示:




  • 创建用户帐户。它现在处于未确认状态;

  • 您可以为您的应用程序生成唯一的确认ID。最简单的方法是使用java.util.UUID.randomUUID()。toString()。 UUID 是一个随机的全球唯一值;

  • 你将ID(例如0123)+帐户存储到数据库以备将来使用;

  • 发送URL + ID( http://yourapp.com/confirm?id=0123 )作为使用javamail的用户的电子邮件;

  • 不显示现在浏览器中的ID;

  • 用户检查收件箱并查看您的信;

  • 用户单击链接并将请求发送到您的网站confirmaion servlet ;

  • 确认servlet将搜索与指定的确认标识相关联的帐户;

  • Confirmaion servlet将帐户设置为已确认状态为使用者可以访问指定的邮箱


I am registering user with email address . but i want to send the user a confirmation link where if they click then their email address gets confirmed

I am using java spring MVC hibernate mysql

解决方案

Among other tools you can use "java mail" package to send emails direclty from your application. Here's the link to API docs Java Mail API

So the scenario could be like the following:

  • User account is created. It's in unconfirmed state now;
  • You generate a unique confirmation ID to your applicaiton. The easiest way is to use java.util.UUID.randomUUID().toString(). UUID is a random globally unique value.;
  • You store the ID (e.g. 0123)+account to the database for future use;
  • Send the URL+ID (http://yourapp.com/confirm?id=0123) as an email using javamail to the user;
  • Do not show the ID in browser now;
  • The user checks inbox and see your letter;
  • The user clicks the link and request is sent to your site confirmaion servlet;
  • Confirmation servlet will search for the account associated with the specified confirmation id;
  • Confirmaion servlet set account to "confirmed state" as obvously the user has access to the specified mail box

这篇关于春季MVC Web应用程序如何确认电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆