zoukankan      html  css  js  c++  java
  • one by one 项目 part 6

    package Controllerservlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    
    import bean.student;
    
    public class FormCheck extends HttpServlet {
    
    	/**
    		 * Constructor of the object.
    		 */
    	public FormCheck() {
    		super();
    	}
    
    	/**
    		 * Destruction of the servlet. <br>
    		 */
    	public void destroy() {
    		super.destroy(); // Just puts "destroy" string in log
    		// Put your code here
    	}
    
    	/**
    		 * The doGet method of the servlet. <br>
    		 *
    		 * This method is called when a form has its tag value method equals to get.
    		 * 
    		 * @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 doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    
    		response.setContentType("text/html;charset=utf-8");
    		PrintWriter out = response.getWriter();
    		HttpSession session= request.getSession(); 
    		ArrayList<student> list = (ArrayList<student>)session.getAttribute("list");
    		System.out.println(1122222);
            for(int i=0;list!=null&&i<list.size();i++){
            	System.out.println(111);
    			String jj = request.getParameter("blogmark"+i);
    			if (!jj.equals("")){
    				student s = list.get(i);
    				String cc=s.getId();
    				String zz=s.getName();
    				String  sql="update studentinfo set blogmark="+jj+" where name = '"+zz+"'and id="+cc+"";
    				System.out.println(sql);
    				 studentservlet.DbUtil  run=new studentservlet.DbUtil();
    				   int n=run.updateSQL(sql);
    				   if(n>=1)
    					   out.print("操作成功");
    				   else
    					   out.print("操作失败");
    			      }
    		}
    			
    			
    		
    	}
    
    	/**
    		 * The doPost method of the servlet. <br>
    		 *
    		 * 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 {
    
    		doGet(request, response);
    	}
    
    	/**
    		 * Initialization of the servlet. <br>
    		 *
    		 * @throws ServletException if an error occurs
    		 */
    	public void init() throws ServletException {
    		// Put your code here
    	}
    
    }
    

      

    实现一组数据的插入

    数据库截图

  • 相关阅读:
    iOS开发allocWithZone介绍
    如何快速的查看一段代码的执行时间
    iOS关于setContentOffset的一些细节问题
    iOS开发libz.dylib介绍
    C#窗体无法接受Keydown事件
    visual studio 2010 C#编程时 没有.NET framework 2.0目标框架的解决办法
    StringBuilder类与String类的区别
    Refresh和Invalidate的比较
    正则表达式
    Queue 先进先出队列的操作
  • 原文地址:https://www.cnblogs.com/frankzone/p/8035353.html
Copyright © 2011-2022 走看看