?? loginaction.java
字號:
/*
* LoginAction.java
*
* Created on 2008年3月4日, 上午9:16
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.IOException;
import javax.servlet.ServletException;
import java.util.ArrayList;
import java.sql.*;
public class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException,SQLException
{LoginForm loginForm=(LoginForm)form;
DBconnect dbc=new DBconnect();
Connection conn=dbc.getConn();
ResultSet rs;
Statement stmt;
String username=loginForm.getUsername();
String password=loginForm.getPassword();
String sql=null;
try
{ sql="select*from user where username='"+username+"'";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
if(rs.equals(""))
{return mapping.findForward("failure");
}
else if(rs.next())
{if(password.equals(rs.getString("password")))
{return mapping.findForward("success");
}
else
{return mapping.findForward("failure");
}
}
stmt.close();
conn.close();
}
catch(Exception e)
{e.printStackTrace();
return mapping.findForward("failure");
}
return mapping.findForward("failure");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -