java页面交互jsp,添加员工到数据库
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>

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();}

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