成功使用HBASE实现Javaweb的增删改查
package org.example.Servlet;标签:name,hao,9.12,request,getParameter,import,日记,String From: https://www.cnblogs.com/zhangmingmkzj/p/17703535.html
import Bean.Bean1;
import org.example.HbaseCRUD;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
@WebServlet(name = "Servletadd1", value = "/Servletadd1")
public class Servletadd1 extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String[] cols=new String[]{"S_No","S_Name","S_Sex","S_Age"};
String hao=request.getParameter("hao");
String name=request.getParameter("name");
System.out.println(name);
String year=request.getParameter("year");
String xingbie=request.getParameter("xingbie");
HbaseCRUD hb=new HbaseCRUD();
try {
hb.addRecord("stu",hao,cols,new String[]{hao,name,xingbie,year});
request.getRequestDispatcher("/success.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
}