码迷,mamicode.com
首页 > 其他好文 > 详细

one by one 项目 part 6

时间:2017-12-14 03:23:42      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:init   servlet   string   dbutil   struct   blog   图片   equal   sharp   

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
	}

}

  技术分享图片

实现一组数据的插入

技术分享图片

数据库截图

技术分享图片

 

one by one 项目 part 6

标签:init   servlet   string   dbutil   struct   blog   图片   equal   sharp   

原文地址:http://www.cnblogs.com/frankzone/p/8035353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!