2 lishdfsdf lishdfsdf 于 2013.11.16 00:19 提问

java web 没有找到字段列表

java beanspackage com.dao.beans;public class beans { private int id; private String name; private String sex; private String birth; private String zhuzhi; private String pas; private String email; private String phone; private int age; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getBirth() { return birth; } public void setBirth(String birth) { this.birth = birth; } public String getZhuzhi() { return zhuzhi; } public void setZhuzhi(String zhuzhi) { this.zhuzhi = zhuzhi; } public String getPas() { return pas; } public void setPas(String pas) { this.pas = pas; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }database.classpackage com.dao.database;import com.dao.beans.beans;import java.sql.Array;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;public class database { Connection conn=null; public Connection conne() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn=DriverManager.getConnection("jdbc:odbc:yonghu","sa", ""); } catch(Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return conn; } public ArrayList
select() { ResultSet ru=null; conn=conne(); beans bean=null; ArrayListarrylist=new ArrayList(); try { Statement stmt=conn.createStatement(); ru=stmt.executeQuery("select * from [user]"); while(ru.next()) { bean=new beans(); bean.setId(ru.getInt("id")); bean.setName(ru.getString("name")); bean.setSex(ru.getString("sex")); bean.setBirth(ru.getString("brith")); bean.setZhuzhi(ru.getString("zhuzhi")); bean.setPas(ru.getString("pas")); bean.setEmail(ru.getString("email")); bean.setPhone(ru.getString("phone")); bean.setAge(ru.getInt("age")); arrylist.add(bean); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { ru.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return arrylist; }}loginpackage com.dao.servlet;import com.dao.database.database;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.dao.beans.beans;public class login extends HttpServlet { /** * Constructor of the object. / public login() { super(); } /* * Destruction of the servlet.
/ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /* * The doPost method of the servlet.

  • * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name=request.getParameter("name"); String pas=request.getParameter("pas"); String location=null; database data=new database(); ArrayListarrylist=new ArrayList(); arrylist=data.select(); beans bean=new beans(); request.setAttribute("name", name); for(int i=0;i<arrylist.size();i++) { if(name.equals(arrylist.get(i).getName())&&pas.equals(arrylist.get(i).getPas())) { location="/dengluchenggong.jsp"; } if(i==arrylist.size()) { location="/error.jsp"; } } RequestDispatcher dispatcher = request.getRequestDispatcher(location); dispatcher.forward(request, response); } public void init() throws ServletException { // Put your code here }}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!