ChangePasswdForm.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.web.form;
- import javax.servlet.http.HttpServletRequest;
- import org.apache.commons.lang.StringUtils;
- import org.apache.struts.action.ActionErrors;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionMessage;
- import com.laoer.comm.util.Util;
- public class ChangePasswdForm
- extends ActionForm {
- private String action;
- private String newpasswd;
- private String newpasswdre;
- private String oldpasswd;
- public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
- ActionErrors errors = new ActionErrors();
- if (StringUtils.isBlank(this.action)) {
- this.action = "show";
- }
- if (this.action.equalsIgnoreCase("change")) {
- if (StringUtils.isBlank(this.newpasswd) || StringUtils.isBlank(this.newpasswdre) ||
- StringUtils.isBlank(this.oldpasswd)) {
- errors.add("error.nullerror", new ActionMessage("error.nullerror"));
- }
- if (newpasswd.length() < 3 || newpasswd.length() > 25) {
- errors.add("error.reg.passwd0", new ActionMessage("error.reg.passwd0"));
- }
- if (!newpasswd.equals(newpasswdre)) {
- errors.add("error.reg.passwd1", new ActionMessage("error.reg.passwd1"));
- }
- newpasswdre = Util.hash(this.newpasswd);
- }
- return errors;
- }
- public void reset(ActionMapping actionMapping, HttpServletRequest servletRequest) {
- }
- public String getAction() {
- return action;
- }
- public String getNewpasswd() {
- return newpasswd;
- }
- public String getNewpasswdre() {
- return newpasswdre;
- }
- public String getOldpasswd() {
- return oldpasswd;
- }
- public void setAction(String action) {
- this.action = action;
- }
- public void setNewpasswd(String newpasswd) {
- this.newpasswd = newpasswd;
- }
- public void setNewpasswdre(String newpasswdre) {
- this.newpasswdre = newpasswdre;
- }
- public void setOldpasswd(String oldpasswd) {
- this.oldpasswd = oldpasswd;
- }
- }