📄 rutiku.jsp
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%!
public String codeToString(String str)
{//处理中文字符串的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}
%>
<%//接收客户端提交的数据
String tkid=codeToString(request.getParameter("tkid"));
if(tkid==null)//无内容则设为空串
tkid="";
String tkclass=codeToString(request.getParameter("tkclass"));
if(tkclass==null)//无内容则设为空串
tkclass="";
String tkvalue=codeToString(request.getParameter("tkvalue"));
if(tkvalue==null)//无内容则设为空串
tkvalue="";
String tkdifficulty=codeToString(request.getParameter("tkdifficulty"));
if(tkdifficulty==null)//无内容则设为空串
tkdifficulty="";
String tkcontent=codeToString(request.getParameter("tkcontent"));
if(tkcontent==null)//无内容则设为空串
tkcontent="";
String tkoption=codeToString(request.getParameter("tkoption"));
if(tkoption==null)//无内容则设为空串
tkoption="";
String tkstandard=codeToString(request.getParameter("tkstandard"));
if(tkstandard==null)//无内容则设为空串
tkstandard="";
%>
<%//构造追加记录SQL语句
String sqlString=null;//SQL语句
sqlString="insert into tiku(tk_id,tk_class,tk_value,tk_difficulty,tk_content,tk_option,tk_standard)"+
" values("+tkid+",'"+tkclass+"','"+tkvalue+"','"+tkdifficulty+"','"+tkcontent+"','"+tkoption+"','"+tkstandard+"')";
%>
<%//执行SQL语句
try
{ Connection con;
Statement sql;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=kaoshi","sa","");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql.executeUpdate(sqlString);
out.print("<script>alert('追加用户成功!');document.location='rutikuview.jsp';</script>");
con.close();
}
catch(SQLException e1)
{
out.print("SQL异常!");
}
%>
<head>
<title>用户注册程序</title>
</head>
<body>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -