找传奇、传世资源到传世资源站!
Java 正文

jsp入门级示例:学生信息管理系统(含数据库脚本)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboard from clipboard
<%@ page language="java" import="java.util.*,com.db.*,java.sql.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'AddStudentData.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> </head> <body> <% request.setCharacterEncoding("UTF-8"); String studentNumber=request.getParameter("studentNumber"); String studentName=request.getParameter("studentName"); String studentSex=request.getParameter("studentSex"); int studentAge=Integer.parseInt(request.getParameter("studentAge")); int studentWeight=Integer.parseInt(request.getParameter("studentWeight")); Connection conn=null; PreparedStatement ps=null; try{ conn=DBConnection.getConn(); ps=conn.prepareStatement("insert into Student values(?,?,?,?,?)"); ps.setString(1,studentNumber); ps.setString(2,studentName); ps.setString(3,studentSex); ps.setInt(4,studentAge); ps.setInt(5,studentWeight); int i=ps.executeUpdate(); if(i>0) response.sendRedirect("StuAdmin.jsp"); }catch(Exception e){ e.printStackTrace(); }finally{ DBConnection.close(null,ps,conn); } %> </body></html>

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复