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

📄 logaction.java

📁 是一个用VB编写得银行ATM机交易的程序
💻 JAVA
字号:
/*
 * LogAction.java
 *
 * Created on 2008年2月21日, 下午2:39
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.myapp.struts;
import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.myapp.struts.LogBean;
import com.myapp.struts.DataStore;
/**
 *
 * @author Administrator
 */
public class LogAction extends Action{
    
    /** Creates a new instance of LogAction */
    
         public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
       ActionErrors errors=new ActionErrors();
       String username=null;
       String userpsw=null;
       HttpSession s=request.getSession();
       String s_user=null;
       
       username=(String)((LogBean)form).getUserName();
       userpsw=(String)((LogBean)form).getUserPsw();
       //处理字符格式
       username=new String(username.getBytes("ISO-8859-1"),"GB2312");
       userpsw=new String(userpsw.getBytes("ISO-8859-1"),"GB2312");
       
       DataStore db=DataStore.getInstance();
       if(db==null){
           errors.add("fail_1",new ActionError("实例为空!"));          
           
           return mapping.findForward("log_error");   //返回登陆失败页面
       }
       
       ResultSet st=null;
       String sql="select * from Reginfo where UserName='"+username+"' and ULogPass='"+userpsw+"'";
       st=db.read(sql);
       if(st!=null && st.next()){
           s_user=(String)s.getAttribute("current_user");
           if(s_user==null){
               s.setAttribute("current_user",username);
               return mapping.findForward("login");
           }else{
               s.removeAttribute("current_user");
               s.setAttribute("current_user",username);
               return mapping.findForward("login");
           }
       }else{
           errors.add("fail_1",new ActionError("对不起,该用户不存在!"));           
           return mapping.findForward("log_error");
       }     
    
         }   
    
}

⌨️ 快捷键说明

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