纯jsp项目,实用mysql数据库

  • L0_224862
    了解作者
  • 1.1MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-14 08:19
    上传日期
使用jsp,mysql,实现的一个jsp单词助记网页,
English.zip
内容介绍
package com.servlet; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; 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.swu.WordDAO; import com.swu.WordInfo; /** * Servlet implementation class Controller */ public class Controller extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public Controller() { super(); } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("------------"); findAll(request, response); // add(request,response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=gbk"); request.setCharacterEncoding("gbk"); doGet(request, response); } public void findAll(HttpServletRequest request, HttpServletResponse response) { try { WordDAO wdao = new WordDAO(); request.setAttribute("pageinfo", wdao.pageSize()); String currpage = request.getParameter("currentpage"); String date = request.getParameter("date1"); request.getSession().setAttribute("date1", date); System.out.println(date); int currentpage = 1; if (currpage != null) { currentpage = Integer.parseInt(currpage); } List<WordInfo> list; list = wdao.findAll(currentpage, date); System.out.println(list.size());//获取数组大小 request.setAttribute("findAll", list); String words =request.getParameter("wordget"); System.out.println(words); String para =request.getParameter("paraget"); System.out.println(para); wdao.addword(words, para); String volIn = request.getParameter("voIn"); System.out.println(volIn); String volGet =request.getParameter("volGet"); String result; if (volIn == volGet) { result = "right"; request.setAttribute("result", result); } else { result = "wrong"; request.setAttribute("result", result); } RequestDispatcher rd = request.getRequestDispatcher("dealTest.jsp"); rd.forward(request, response); } catch (Exception e) { e.printStackTrace(); } } }
评论
    相关推荐