⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fufenzhi.jsp

📁 这是一个在线考试系统
💻 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;
   }  
}
%>
<a href=kaotiji.jsp>返回</a><br>
<HTML>
<BODY>
<%
  String sqlString=null;//SQL语句
   String sqlString1=null;//SQL语句
   String xuanx=codeToString(request.getParameter("xuanx"));
   String sjno1=codeToString(request.getParameter("sjno"));
  
  if(sjno1==null||sjno1.trim().length()==0)//SQL语句不变
  {sqlString=new String("SELECT * FROM kaoti");
   sqlString1 = new String("update kaoti set kt_value=kt_value");
  }
  else
  {sqlString=new String("SELECT * FROM  kaoti where sj_no= '"+sjno1.trim()+"'");
   //sqlString1 = new String("update kaoti set kt_value='"+sjno1.trim()+"' where kt_bh in('1','01','001','0001')");
   if(xuanx==null||xuanx.trim().length()==0)
   sqlString1 = new String("update kaoti set kt_value='"+sjno1.trim()+"' where kt_bh in('1','01','001','0001')");
   else 
     {if(xuanx.trim().length()==1)
     sqlString1 = new String("update kaoti set kt_value='"+sjno1.trim()+"' where kt_bh='1'");
     else 
      if(xuanx.trim().length()==2)
      sqlString1 = new String("update kaoti set kt_value='"+sjno1.trim()+"' where kt_bh='01'");
      else  if(xuanx.trim().length()==3)
       sqlString1 = new String("update kaoti set kt_value='"+sjno1.trim()+"' where kt_bh='001'");
       else
      sqlString1 = new String("update kaoti set kt_value='"+sjno1.trim()+"' where kt_bh='0001'");
        
     }
   }
 %>
 <% Connection con;
    Statement sql; 
    ResultSet rs;
    try
    {
      Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    }
    catch(ClassNotFoundException e)
    {
      out.print("类找不到!");
    }
    try 
    {  
         con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=kaoshi","sa","");
         sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
         rs=sql.executeQuery(sqlString);
         Statement stmt = con.createStatement();
	 	 stmt.executeUpdate(sqlString1);
         out.print("<Table Border>");
         out.print("<form action=fufenzhi.jsp method=post>");
         out.print("<TR><td>条件:</td>");
         out.print("<td colspan=12>");
         out.print("<select name=xuanx>"); 
         out.print("<option value='' selected>所有</option>");
         out.print("<option value='1'>单选题</option>");
         out.print("<option value='01'>多选题</option>");
         out.print("<option value='001'>填空题</option>");
         out.print("<option value='0001'>判断题</option></select>");
         out.print("赋分值:<input type=text name=sjno>");
         out.print("<input type=submit value=提交>");
         out.print("</td></tr></form>");     
        con.close();
       
     }
   catch(SQLException e1) 
   {
      out.print("SQL异常!");
   }
 %>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -