jsp登录检测问题
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException {
LoginForm login = (LoginForm) form;// TODO Auto-generated method stub
Class.forName("org.postgresql.Driver");
String url="jdbc:postgresql://localhost:/test";
String user="postgres";
String password="1234";
Connection con=DriverManager.getConnection(url,user,password);
Statement stmt=con.createStatement();
ResultSet rs;
String sql="selcet * from manager";
rs= stmt.executeQuery(sql);
while(rs.next())
{
String name=rs.getString(2);
String pass=rs.getString(3);
if(name.equals(login.getName()) && pass.equals(login.getPassword()))
{
request.setAttribute("manager", login.getName());
request.setAttribute("mpass", login.getPassword());
return mapping.findForward("ok");
}
}
return null;
}
这是我做的登录的代码,但出现了以下错误:
javax.servlet.ServletException: No suitable driver
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getConnection(DriverManager.java:545)
java.sql.DriverManager.getConnection(DriverManager.java:171)
com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:46)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
请问是怎么回事啊
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)