<span style="font-family: 'ms shell dlg'; background-color: rgb(255, 255, 255);">request.getSchema()</span><span style="font-family: 'ms shell dlg'; background-color: rgb(255, 255, 255);"> </span><span style="font-family: 'ms shell dlg'; background-color: rgb(255, 255, 255);">返回当前页面使用的协议,http 或是 https;</span>
request.getServerName() 返回当前页面所在的服务器的名字;
request.getServerPort() 返回当前页面所在的服务器使用的端口,就是80;
request.getContextPath() 返回当前页面所在的应用的名字;
/**
* 添加注册信息,发送验证邮件
*
* @return
* @throws Exception
*/
public String add() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
ShoppingCust shoppingLoginUser = new ShoppingCust();
shoppingLoginUser.setUsername(request.getParameter("username"));
shoppingLoginUser.setEMail(request.getParameter("eMail"));
shoppingLoginUser.setState("0");
//shoppingLoginUser.setLastVisitUrl("");
shoppingLoginUser.setPassword(request.getParameter("password"));
int primaryKey = shoppingCustService.insert(shoppingLoginUser);
StringBuffer email_content = new StringBuffer();
email_content.append("尊敬的<font color='red' font-size='20px;'>" + shoppingLoginUser.getUsername() + "</font>:<br/>");
email_content.append("请点击下面的链接以验证您的邮箱(若链接不可点击,请复制并粘帖该链接到浏览器地址栏中访问)。");
email_content.append("<a href='");
email_content.append(request.getScheme());
email_content.append("://");
email_content.append(request.getServerName());
email_content.append(":");
email_content.append(request.getServerPort());
email_content.append(request.getContextPath());
email_content.append("/register_activeAccount.do?");
email_content.append(new DESPlus().encrypt("loginUserId=" + primaryKey + "&nowDate=" + System.currentTimeMillis()));
email_content.append("'>");
email_content.append(request.getScheme());
email_content.append("://");
email_content.append(request.getServerName());
email_content.append(":");
email_content.append(request.getServerPort());
email_content.append(request.getContextPath());
email_content.append("/register_activeAccount.do?");
email_content.append(new DESPlus().encrypt("loginUserId=" + primaryKey + "&nowDate=" + System.currentTimeMillis()));
email_content.append("</a><br/>");
email_content.append("若您并未在天津分销网站上注册,请忽略本邮件,链接将自动失效。<br/>");
email_content.append("该邮件由系统发送,请勿回复<br/>");
email_content.append("天津分销系统<br/>");
request.setAttribute("mailbox", shoppingLoginUser.getEMail());
SendMail.sendMailToAccount(shoppingLoginUser.getEMail(), "天津分销系统注册激活", email_content.toString(), "html");
return "getMail";
}