java页面交互jsp,添加员工到数据库

 时间:2024-10-12 23:06:15

1、先编写html页面<!DOCTYPE html><html><head><met锾攒揉敫a charset="UTF-8"><title>Insert title here</title></head><body><div><form action="add" method="post"><fieldset><legend>添加员工</legend>姓名:<input type="text" name="name"><br>年龄:<input type="text" name="age"><br>工资:<input type="text" name="sal"><br><input type="submit" value="提交"></fieldset></form></div></body></html>

java页面交互jsp,添加员工到数据库

3、// 获取参数String name = request.getParameter("name");// postname = new String(name.getBytes("iso-8859-1"), "utf-8");int age = Integer.parseInt(request.getParameter("age"));Double sal = Double.parseDouble(request.getParameter("sal"));addEmp(name,age,sal);//重定向response.sendRedirect("show");System.out.println("添加成功");out.close();}

java页面交互jsp,添加员工到数据库

5、pstm.setInt(2, age);pstm.setDouble(3, sal);pstm.executeUpdate();} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

java页面交互jsp,添加员工到数据库
  • Navicat过了试用期继续试用方法
  • eclipse新建没有web项目怎么办
  • 错误:You have an error in your SQL syntax;
  • 如何使用SQLyog在数据库表中增加字段
  • eclipse如何在包里新建java类
  • 热门搜索
    旅游收入 旅游旅游 崇礼旅游 乌镇旅游股份有限公司 东戴河旅游 昆山旅游景点 五指山旅游 中国国家旅游局 西安旅游集团 兴宁旅游