河北省重大技术需求征集系统原型

该项目今天全部完成套用了一个框架比较生疏,许多东西以后会完善的。

今天完善过程遇到很多问题后面会一个个列举并写出解决方法:

1、验证码问题(checkcode.java、login.jsp、login.java)

在后续代码中(checkcode.java、login.jsp、login.java)三部分展示。checkcode.java生成验证码图片在login.html中显示图片并设置点击事件,login.java中验证验证码的正确性,

2、框架页面点击跳转不存在于一个页面问题(代码在indexmain.jsp中)

用到了HTML中的,标签定义及使用说明

login.java













S

class="loginBox">

欢迎登陆

class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item_3"> class="btn"/>
class="item_4"> 还没有账号?立即注册

mima.java(修改密码)















class="loginBox">

注册

class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item_3"> class="btn"/>
class="item_4"> 已注册返回

register.java














class="loginBox">

注册

class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item">
class="icon">
class="txt">
class="item_3"> class="btn"/>
class="item_4"> 已注册我要登录

work.jsp(无用东西可加可不加)

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>




    
    
    

    jQuery/HTML5/css3精美唯美图片Y轴展示
    
    
    



   
    
class="wrapper init">
    class="content">
  • class="item" >
    class="inner">
    class="bjPic" >
    class="dir" >

    那一瞬

    class="showBox">
    class="showBox-dir" >

    那一瞬,我飞升成仙,不为长生,只为佑你平安喜乐

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一刻

    class="showBox">
    class="showBox-dir">

    那一刻,我升起风马,不为祈福,只为守候你的到来

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一日

    class="showBox">
    class="showBox-dir">

    那一日,我磨一砂石,不为修性,只为丢进你的心海

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一夜

    class="showBox">
    class="showBox-dir">

    那一夜,我彻宿低吟,不为参悟,只为寻你的气息

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一天

    class="showBox">
    class="showBox-dir">

    那一天,闭目在经殿香雾中,蓦然听见,你颂经中的真言

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一月

    class="showBox">
    class="showBox-dir">

    那一月,我摇动所有经筒,不为超度,只为触摸你指尖

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一年

    class="showBox">
    class="showBox-dir">

    那一年,磕长头匍匐在山路,不为觐见,只为贴着你的温暖

    class="close">
  • class="item">
    class="inner">
    class="bjPic">
    class="dir">

    那一世

    class="showBox">
    class="showBox-dir">

    那一世,转山转水转佛塔,不为修来世,只为途中相见

    class="close">

zhengji.html(征集信息填报)





Insert title here

    


    

class="callout" align="center">河北省重大技术需求征集表

class="wzc-table" border="1" cellspacing="0">
技术需求名称:
重大科技需求概述:
研究类型: 基础研究 应用研究 试验发展 研究发展与成果应用 技术推广与科技服务
时间:
技术需求合作模式: 独立开发 技术转让 合作开发 技术入股
计划总投资
class="wzc-btn" style="width: 200px;">

index.jsp(显示所有基本数据并不完善)

<%@page import="util.util"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="Bean.zhengjis"%>
<%@page import="Dao.dao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




展示数据
 
  


class="layui-table"> <% ArrayList zhengjis = new ArrayList(); dao dao = new dao(); int num=0; dao.showall(zhengjis); for (int i =0; i < zhengjis.size(); i++) { zhengjis A = zhengjis.get(i); num+=1; %> <% } %>
序号 技术需求名称 提交日期 需求状态
<%=num%> <%=A.getMingcheng()%> <%=A.getDate() %> <%=A.getShenghe()%>

index2.jsp(显示查询信息此jsp文件与index.jsp相关联无法自己启动会因为要从index.jsp获取数据)

<%@page import="util.util"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="Bean.zhengjis"%>
<%@page import="Dao.dao"%>
<%@page import="servlet.shenhe"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




展示数据 
  



        class="layui-table">
    
    <%
        ArrayList  zhengjis =(ArrayList)request.getAttribute("zhengji");;
        
        int num=0;
            for (int i =0; i < zhengjis.size(); i++) {
                zhengjis A = zhengjis.get(i);    
        %>
        
        <%
            }
        %>
    
技术需求名称 重大科技需求概述 研究类型 技术需求合作模式 计划总投资
<%=A.getMingcheng()%> <%=A.getGaishu()%> <%=A.getLeixing() %> <%=A.getMoshi()%> <%=A.getTouzi()%>

 

后端:

Bean包

user.java

package Bean;

public class user {
private String number;
private String password;
private String phone;
private String address;
public String getNumber() {
    return number;
}
public void setNumber(String number) {
    this.number = number;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}
public String getPhone() {
    return phone;
}
public void setPhone(String phone) {
    this.phone = phone;
}
public String getAddress() {
    return address;
}
public void setAddress(String address) {
    this.address = address;
}
}

zhengjis.java

package Bean;

public class zhengjis {
    private String mingcheng;
    private String gaishu;
    private String leixing;
    private String moshi;
    private String touzi;
    private String shenghe;
    private String date;
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public String getMingcheng() {
        return mingcheng;
    }
    public void setMingcheng(String mingcheng) {
        this.mingcheng = mingcheng;
    }
    public String getShenghe() {
        return shenghe;
    }
    public void setShenghe(String shenghe) {
        this.shenghe = shenghe;
    }
    public String getGaishu() {
        return gaishu;
    }
    public void setGaishu(String gaishu) {
        this.gaishu = gaishu;
    }
    public String getLeixing() {
        return leixing;
    }
    public void setLeixing(String leixing) {
        this.leixing = leixing;
    }
    public String getMoshi() {
        return moshi;
    }
    public void setMoshi(String moshi) {
        this.moshi = moshi;
    }
    public String getTouzi() {
        return touzi;
    }
    public void setTouzi(String touzi) {
        this.touzi = touzi;
    }
    
}

Dao包下(工具类):

dao.java

package Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import Bean.user;
import Bean.zhengjis;
import util.util;

public class dao {
    public void add(user A) throws ClassNotFoundException, SQLException {
        Connection connection = util.getConnection();
        String sql = "insert into user(number,password,phone,address) values(?,?,?,?)";
        PreparedStatement preparedStatement = null;
        try {
             //������䴫�����
             preparedStatement = connection.prepareStatement(sql);
           // preparedStatement = connection.prepareStatement(sql);
             preparedStatement.setString(1, A.getNumber());
             preparedStatement.setString(2, A.getPassword());
             preparedStatement.setString(3, A.getPhone());
             preparedStatement.setString(4, A.getAddress());
             preparedStatement.executeUpdate();
             } catch (SQLException e) {
                // TODO Auto-generated catch block
               e.printStackTrace();
            }finally {

            }
    }
    public void add1(zhengjis A) throws ClassNotFoundException, SQLException {
        Connection connection = util.getConnection();
        String sql = "insert into zhengji(mingcheng,gaishu,leixing,moshi,touzi,shenghe,shijian) values(?,?,?,?,?,?,?)";
        PreparedStatement preparedStatement = null;
        try {
             //������䴫�����
             preparedStatement = connection.prepareStatement(sql);
           // preparedStatement = connection.prepareStatement(sql);
             preparedStatement.setString(1, A.getMingcheng());
             preparedStatement.setString(2, A.getGaishu());
             preparedStatement.setString(3, A.getLeixing());
             preparedStatement.setString(4, A.getMoshi());
             preparedStatement.setString(5, A.getTouzi());
             preparedStatement.setString(6, A.getShenghe());
             preparedStatement.setString(7, A.getDate());
             preparedStatement.executeUpdate();
             } catch (SQLException e) {
                // TODO Auto-generated catch block
               e.printStackTrace();
            }finally {

            }
    }
    public void xiugaimima(String yonghu,String password2) throws ClassNotFoundException, SQLException {
        Connection connection = util.getConnection();
        String sql = " update user set password = ? where number = ?";
        PreparedStatement preparedStatement = null;
        try {
             //������䴫�����
             preparedStatement = connection.prepareStatement(sql);
           // preparedStatement = connection.prepareStatement(sql);
           
             preparedStatement.setString(1, password2);
             preparedStatement.setString(2, yonghu);
             preparedStatement.executeUpdate();
             } catch (SQLException e) {
                // TODO Auto-generated catch block
               e.printStackTrace();
            }finally {

            }}
        public void showall(ArrayList ke) throws ClassNotFoundException, SQLException{
            
             String sql1 ="select * from zhengji";
              //������䴫�����
             Connection connection = util.getConnection();
                 try {
                     PreparedStatement ps = connection.prepareStatement(sql1);
                     ResultSet rs =  ps.executeQuery();
                     
                 while(rs.next()) {
                     System.out.println("1”");
                    zhengjis A = new zhengjis();
                    A.setMingcheng(rs.getString(1));
                    A.setShenghe(rs.getString(6));
                    A.setDate(rs.getString(7));
                     ke.add(A);
                   }
                 } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
          
      }
        public void showall1(ArrayList ke) throws ClassNotFoundException, SQLException{
            
             String sql1 ="select * from zhengji";
              //������䴫�����
             Connection connection = util.getConnection();
                 try {
                     PreparedStatement ps = connection.prepareStatement(sql1);
                     ResultSet rs =  ps.executeQuery();
                     
                 while(rs.next()) {
                     System.out.println("1”");
                    zhengjis A = new zhengjis();
                    A.setMingcheng(rs.getString(1));
                    A.setGaishu(rs.getString(2));
                    A.setLeixing(rs.getString(3));
                    A.setMoshi(rs.getString(4));
                    A.setTouzi(rs.getString(5));
                    A.setShenghe(rs.getString(6));
                     ke.add(A);
                   }
                 } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
          
      }
        public void update(String mm,String result) throws ClassNotFoundException, SQLException {
            Connection connection = util.getConnection();
            String sql = "update zhengji set shenghe = ?  where    mingcheng = ?";
            PreparedStatement preparedStatement = null;
            try {
                 //������䴫�����
                 preparedStatement = connection.prepareStatement(sql);
               // preparedStatement = connection.prepareStatement(sql);
                 preparedStatement.setString(1,result);
                 preparedStatement.setString(2, mm);

                 preparedStatement.executeUpdate();
                 } catch (SQLException e) {
                    // TODO Auto-generated catch block
                   e.printStackTrace();
                }finally {

                }
        }
        public void select(ArrayList zhengjis,String name) throws ClassNotFoundException, SQLException{
             String sql1 ="select * from zhengji where mingcheng = ?";
             Connection connection = util.getConnection();
                 try {
                     PreparedStatement ps = connection.prepareStatement(sql1);
                      ps.setString(1, name);
                     ResultSet rs =  ps.executeQuery();  
                 while(rs.next()) {
                     zhengjis A = new zhengjis();
                     
                     A.setGaishu(rs.getString(2));
                     A.setLeixing(rs.getString(3));
                     A.setMoshi(rs.getString(4));
                     A.setTouzi(rs.getString(5));
                     A.setMingcheng(rs.getString(1));
                     zhengjis.add(A);
                   }
                 } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
          
      }
//    }
//    public void add2(agent A) throws ClassNotFoundException, SQLException {
//        Connection connection = util.getConnection();
//        String sql = "insert into agent(AgentAddress,AgentName,AgentID,AgentPhone) values(?,?,?,?)";
//        PreparedStatement preparedStatement = null;
//        try {
//             //������䴫�����
//             preparedStatement = connection.prepareStatement(sql);
//           // preparedStatement = connection.prepareStatement(sql);
//             preparedStatement.setString(1, A.getAgentAddress());
//             preparedStatement.setString(2, A.getAgentName());
//             preparedStatement.setString(3, A.getAgentID());
//             preparedStatement.setString(4, A.getAgentPhone());
//             preparedStatement.executeUpdate();
//             } catch (SQLException e) {
//                // TODO Auto-generated catch block
//               e.printStackTrace();
//            }finally {
//
//            }
//    }
}

servlet包下:

checkcode.java:这个文件中是我遇到的第一个问题验证码,主要生成验证码的图片再通过session获取生成验证码数据在login.java里进行与前端的数据比较

package servlet;

import javax.imageio.ImageIO;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;

@WebServlet(name = "CheckCode", value = "/CheckCode")
public class CheckCode extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //创建一个对象
        int width = 100;
        int height = 50;
        BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_3BYTE_BGR);
        //填充背景颜色
        Graphics g = image.getGraphics();//画笔
        g.setColor(Color.cyan);//设置画笔颜色
        g.fillRect(0,0,width,height);
        //画边框
        g.setColor(Color.black);
        g.drawRect(0,0,width-1,height-1);
        //随机码
        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        Random ran = new Random();
        StringBuilder sb = new StringBuilder();
        for(int i=1;i<=4;i++){
            int index = ran.nextInt(str.length());
            char ch = str.charAt(index);
            sb.append(ch);
            g.drawString(ch+"",width/5*i,height/2);
        }
        String checkCode_session = sb.toString();
        //将验证码存入session
        request.getSession().setAttribute("checkCode_session",checkCode_session);
        //随机划线
        g.setColor(Color.BLUE);
        for(int i=1;i<4;i++){
            int x1 = ran.nextInt(width);
            int y1 = ran.nextInt(height);

            int x2 = ran.nextInt(width);
            int y2 = ran.nextInt(height);
            g.drawLine(x1,y1,x2,y2);
        }
        //图片输出
        ImageIO.write(image,"png",response.getOutputStream());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}

login.java:这个登录我加入了一些账号、密码、验证码是否存在是否正确并给出相应的结果。

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.WindowConstants;

import Bean.user;
import util.util;

/**
 * Servlet implementation class register
 */
@WebServlet("/login")
public class login extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public login() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
                // TODO Auto-generated method stub
                        request.setCharacterEncoding("utf-8");
                        //������Ӧ���ı�����
                        int index=-1;
                        response.setContentType("text/html;charset=utf-8");//设置字符集
                        String usernames = request.getParameter("username");
                        String passwords=request.getParameter("password1");
                        String works=request.getParameter("work");
                        String verifyc  = request.getParameter("yanzhengma");
                        HttpSession sess=request.getSession();
                        String name11=(String) sess.getAttribute("checkCode_session");//验证码
                        System.out.println(name11);
                        String svc =(String) request.getSession().getAttribute("sessionverify");
                        PrintWriter out=response.getWriter();
                        HttpSession session=request.getSession();
                        session.setAttribute("name", usernames);//获取登录者信息
                        Connection connection = null;
                        int i=0;int count=0;
            
                        String username1[]=new String[50];
                        String password2[]=new String[50];
                        String shenfen1[]=new String[50];
                        try {
                            connection = util.getConnection();
                        } catch (ClassNotFoundException | SQLException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        PreparedStatement pre = null;
                        try {
                            pre = connection.prepareStatement("select * from user");
                        } catch (SQLException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                        ResultSet set = null;
                        try {
                            set = pre.executeQuery("select * from user");
                        } catch (SQLException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } 
                        try {
                            while(set.next())
                            {
                                username1[i]=set.getString("number");
                                password2[i]=set.getString("password");
                                i++;
                                count++;
                            }
                        } catch (SQLException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                        if(verifyc.equals(name11))
                        {
                            System.out.println("验证码");
                        
                        for(int j=0;j) {
                        if(username1[j].equals(usernames))
                        {
                            
                            System.out.println("dasdasd");
                            if(password2[j].equals(passwords))
                            {
                                System.out.println("shuichen");
                                    index=1;
                                    response.sendRedirect("indexmain.jsp");
                            }
                            else
                            {
                    
                                System.out.println("chen");
                                out.print("");
                            }
                        }
                        else 
                        {
                            System.out.println("huo");
                            out.print("");
                        }
                        }
                        
                        }
                        else
                        {
                            out.print("");
                        }
//                        System.out.println(number);
            }}

mima.java(这个时用来修改密码的其中包括密码比较等)

package servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.dao;
import util.util;
import Bean.user;
/**
 * Servlet implementation class dengji
 */
@WebServlet("/mima")
public class mima extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public mima() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    request.setCharacterEncoding("utf-8");
    //������Ӧ���ı�����
    response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
System.out.println("dasdasd");
String yonghu=request.getParameter("yonghu");
String password=request.getParameter("password");
String password1=request.getParameter("password1");
if(password.equals(password1)) {
    
    
Connection connection = null;
int i=0;int count=0;
String username1[]=new String[50];
dao A=new dao();
try {
    connection = util.getConnection();
} catch (ClassNotFoundException | SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
PreparedStatement pre = null;
try {
    pre = connection.prepareStatement("select * from user");
} catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
ResultSet set = null;
try {
    set = pre.executeQuery("select * from user");
} catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} 
try {
    while(set.next())
    {
        username1[i]=set.getString("number");
        System.out.println(username1[i]);
        i++;
        count++;
    }
} catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
for(int j=0;j) {
    if(username1[j].equals(yonghu))
    {
            
                try {
                    A.xiugaimima(yonghu, password1);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
    }
}}
else
{
    response.getWriter().print("");
}
}}

register.java(注册)

package servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.dao;
import Bean.user;
/**
 * Servlet implementation class dengji
 */
@WebServlet("/register")
public class register extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public register() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.setCharacterEncoding("utf-8");
        //������Ӧ���ı�����
        response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
        
        dao A =new dao();
        String password = request.getParameter("password");
        String username=request.getParameter("yonghu");
        String phone=request.getParameter("id");
        String password1=request.getParameter("password1");
        String address=request.getParameter("address");
        if(password.equals(password1))
        {user B = new user();
        B.setNumber(username);
        B.setPassword(password);
        B.setPhone(phone);
        B.setAddress(address);
        try {
            A.add(B);
        } catch (ClassNotFoundException | SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
            
        }
        else {
            System.out.println("密码");
            response.getWriter().print("");
        
    }
    }
}

select.java

package servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Bean.zhengjis;

import Dao.dao;
import util.util;

/**
 * Servlet implementation class add
 */
@WebServlet("/select")
public class select extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public select() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        
        // TODO Auto-generated method stub
            request.setCharacterEncoding("utf-8");
            
            response.setContentType("text/html;charset=utf-8");
            String mingcheng = request.getParameter("mm");;
            ArrayList  zhengji = new ArrayList();
            dao dao=new dao();
            if(mingcheng!=null)
            {
                try {
                    dao.select(zhengji,mingcheng);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                request.setAttribute("zhengji",zhengji);//setAttribute() 方法添加指定的属性,并为其赋指定的值。
                request.getRequestDispatcher("index2.jsp").forward(request, response);
                
            }
            else {
                response.getWriter().write("查询数据不存在请重新输入。");
            }
//            else if(number!=null)    {
//                    try {
//                        dao.select1(book,number);
//                    } catch (ClassNotFoundException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    } catch (SQLException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                    request.setAttribute("people",people);
//                    request.getRequestDispatcher("chakan.jsp").forward(request, response);
//                }
//            else if(minzu!=null)    {
//                    try {
//                        dao.select4(people,minzu);
//                    } catch (ClassNotFoundException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    } catch (SQLException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                    request.setAttribute("people",people);
//                    request.getRequestDispatcher("chakan.jsp").forward(request, response);
//                }
//                else     {
//                    try {
//                        dao.select5(people,jiaoyuchengdu);
//                    } catch (ClassNotFoundException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    } catch (SQLException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                    request.setAttribute("people",people);
//                    request.getRequestDispatcher("chakan.jsp").forward(request, response);
//                }
        
                
            }}

shenhe.java对数据进行审核

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.WindowConstants;

import Bean.user;
import Bean.zhengjis;
import util.util;
import Dao.dao;
/**
 * Servlet implementation class sehnhe
 */
@WebServlet("/shenhe")
public class shenhe extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public shenhe() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
                request.setCharacterEncoding("utf-8");
                //������Ӧ���ı�����
                response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
                System.out.println("chen");
                String mm=request.getParameter("mm");
                String nn=request.getParameter("nn");
                dao A=new dao();
                String result="";
                System.out.println(mm);
                if(nn.equals("1"))
                {
                    result="通过";
                }
                else
                {
                    result="未通过";
                }
                zhengjis B = new zhengjis();
                
                try {
                    A.update(mm,result);
                     
                } catch (ClassNotFoundException | SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                response.sendRedirect("index.jsp");
            }
    }

zhengji1.java(相当于上传一个数据表了)

package servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Bean.zhengjis;
import Dao.dao;
/**
 * Servlet implementation class zhengji1
 */
@WebServlet("/zhengji1")
public class zhengji1 extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public zhengji1() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.setCharacterEncoding("utf-8");
        //������Ӧ���ı�����
        response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
        
        dao A =new dao();
        String mingcheng = request.getParameter("mingcheng");
        String gaishu=request.getParameter("gaishu");
        String leixing=request.getParameter("leixing");
        String [] lei  = request.getParameterValues("leixing");
         leixing = Arrays.toString(lei);
        String moshi=request.getParameter("moshi");
        String touzi=request.getParameter("touzi");
        String shijian=request.getParameter("date");
//        System.out.println();
        System.out.println(mingcheng);
        String shenghe="未审核";
        zhengjis B = new zhengjis();
        System.out.println("213123");
            B.setMingcheng(mingcheng);
            B.setGaishu(gaishu);
            B.setLeixing(leixing);
            B.setTouzi(touzi);
            B.setMoshi(moshi);
            B.setShenghe(shenghe);
            B.setDate(shijian);
        try {
                A.add1(B);
        } catch (ClassNotFoundException | SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        response.getWriter().print("");
        }
        
    }

 这是本次项目文件以及css样式大家可以提取

链接:https://pan.baidu.com/s/1gHHWfzzsG6fwdv1Mmdv10A
提取码:jyt9

你可能感兴趣的:(河北省重大技术需求征集系统原型)