小荣荣555 2013-11-15 16:19
浏览 1136

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 }}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿