modquestion.jsp
上传用户:apbaoyuan
上传日期:2021-02-12
资源大小:1015k
文件大小:2k
- <%@page import="java.sql.*"%>
- <%@page import="java.util.*"%>
- <%@page contentType="text/html;charset=GB2312"%>
- <%@include file="opendata.jsp"%>
- <%@include file="check.jsp"%>
- <%!
- int isempty(String str) //判断递交的字符串是否为空
- {
- if(str.length() ==0)
- return (0);
- else return (1);
- }
- %>
- <%!
- String transfer(int i) //将时间数值转换为标准格式
- {
- if(i>=10)
- return (String.valueOf(i));
- else return ("0"+String.valueOf(i));
- }
- %>
- <%
- try{
- request.setCharacterEncoding("GB2312");
- String question = request.getParameter("question");
- int questionid = Integer.parseInt(request.getParameter("questionid"));
- int year,month,day,hour,minute,second;
- String time;
- GregorianCalendar calendar;
- calendar = new GregorianCalendar();
- year = calendar.get(Calendar.YEAR);
- month = calendar.get(Calendar.MONTH)+1;
- day = calendar.get(Calendar.DAY_OF_MONTH);
- hour = calendar.get(Calendar.HOUR_OF_DAY);
- minute = calendar.get(Calendar.MINUTE);
- second = calendar.get(Calendar.SECOND);
- time = year +"-"+transfer(month)+"-" + transfer(day) +" "+transfer(hour)+":"+transfer(minute)+":"+transfer(second);
- if(question.length()==0)
- {
- String errmsg = "问题不可为空!!!";
- out.print("<center><font color=green size=5>错误信息<hr></font><font color=red>"+errmsg+"</font><hr>");
- out.print("<input type=button value=回上一页 onclick=history.back()>");
- }
- else
- {
- //更新主题
- sql = "update Questions set Question = '"+question+"',Date = '"+time+"',IsVisable = 0 where QuestionID = "+questionid;
- smt.executeUpdate(sql);
- response.sendRedirect("edit.jsp?questionid="+questionid);
- }}
- catch (Exception e) {
- e.getStackTrace();
- }
- %>
- <html>
- <title>错误信息</title>
- </html>