📄 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 + -