⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registeraction.java

📁 基于JAVA的一个注册系统 最初只是为了公司做演示使用
💻 JAVA
字号:
package registerapp;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.io.*;
import org.apache.struts.util.*;

/*
* @author ye fei
* @version 1.00, 2003/04/15
* @copyright www.studyjava.com
*/
public class RegisterAction extends Action {

public ActionForward perform (ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest req,
                              HttpServletResponse res) {
 /**
  * Cast the form to the RegisterForm
  */
 RegisterForm rf = (RegisterForm) form;
 /**
  * Get user information
  */
 String username  = rf.getUserName();
 String password1 = rf.getPassword1();
 String password2 = rf.getPassword2();
 String UserSex= rf.getUserSex();
 String Email= rf.getUserEmail();
 /**
  * Validate the request parameters specified by the user
  */
 ActionErrors errors = new ActionErrors();
 /**
  *  Apply business logic
  */
 if (password1.equals(password2)) {
    try {
       /**
        * New UserDirectory object created.
        */
       UserDirectory UserDir=new UserDirectory();
       /**
        * Registe the user.
        * and if success, return to success.html.
        */
       UserDir.setUser(username,password1,UserSex,Email);
       return mapping.findForward("success");

    } catch (UserDirectoryException e) {
        errors.add(ActionErrors.GLOBAL_ERROR,
        new ActionError("error.password.match"));
    }

 }
 /**
  * Check the errors.
  * if errors is empty then resume and continue.
  * else forward to this jsp again and print the errors
  */
 if (!errors.empty()) {
        saveErrors(req, errors);
         return (new ActionForward(mapping.getInput()));
    }
/**
 *return to success.html.
 */
return mapping.findForward("success");
}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -