📄 xiugai.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;
}
}
%>
<%//接收要修改的用户ID号
long tk_no=Long.parseLong(request.getParameter("tk_no"));
%>
<%//接收客户端提交的数据
String tk_id=codeToString(request.getParameter("tk_id"));
if(tk_id==null)//无内容则设为空串
tk_id="";
String tk_class=codeToString(request.getParameter("tk_class"));
if(tk_class==null)//无内容则设为空串
tk_class="";
String tk_value=codeToString(request.getParameter("tk_value"));
if(tk_value==null)//无内容则设为空串
tk_value="";
String tk_difficulty=codeToString(request.getParameter("tk_difficulty"));
if(tk_difficulty==null)//无内容则设为空串
tk_difficulty="";
String tk_content=codeToString(request.getParameter("tk_content"));
if(tk_content==null)//无内容则设为空串
tk_content="";
String tk_option=codeToString(request.getParameter("tk_option"));
if(tk_option==null)//无内容则设为空串
tk_option="";
String tk_standard=codeToString(request.getParameter("tk_standard"));
if(tk_standard==null)//无内容则设为空串
tk_standard="";
%>
<%//构造修改记录SQL语句
String sqlString=null;//SQL语句
sqlString="update tiku set tk_id='"+tk_id+"',tk_class='"+tk_class+"',tk_value='"+tk_value+"',tk_difficulty='"+tk_difficulty+"',tk_content='"+tk_content+"',tk_option='"+tk_option+"',tk_standard='"+tk_standard+"' where tk_no="+tk_no;
%>
<%//执行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();
sql.executeUpdate(sqlString);
out.print("<script>alert('恭喜你,修改成功!');document.location='sql.jsp';</script>");
con.close();
}
catch(SQLException e1)
{
out.print("SQL异常!");
}
%>
<head>
<title>修改用户资料程序</title>
</head>
<body>
<center>
<table border="1" width="700">
<tr>
<td width="100%" colspan="2" align="center">修改用户资料程序</td>
</tr>
<tr>
<td width="100%" colspan="2">修改用户资料成功!</td>
</tr>
</table>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -