是否可以在tomcat中编辑一个类文件并重新编译该单个文件?

时间:2014-05-30 03:29:16

标签: java jsp tomcat servlets

我有一个由tomcat编写的考试系统,现在,我发现程序中有一个错误,我没有源代码,但我用jd-gui反编译它,我想要什么做 很简单,只需替换这行代码

ResultSet rs = conn.createStatement().executeQuery("select id FROM EXAMINEE ");

ResultSet rs = st.executeQuery("select id FROM EXAMINEE ");

我怎么能这样做,我想编译那个 java文件进入类,我试过javac,但是错误太多了, 下面是我想要修改的反编译文件

package maozf.admin;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import maozf.Databases;
import maozf.ExamPaper;
import maozf.Examinee;
import maozf.Officer;

@WebServlet({"/admin/adminExaminee.jsp"})
public class AdminExaminee
  extends HttpServlet
{
  private static final long serialVersionUID = 1L;

  protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try
    {
      HttpSession session = request.getSession();
      ServletContext application = request.getSession().getServletContext();
      Officer officer = (Officer)session.getAttribute("admin");
      if (officer == null) {
        response.sendRedirect("index.jsp");
      }
      String oper = request.getParameter("oper");
      String name = request.getParameter("name");
      String idcard = request.getParameter("idcard");
      String duty = request.getParameter("duty");
      String dept = request.getParameter("dept");
      String area = request.getParameter("area");
      String papertypeid = request.getParameter("papertypeid");
      String id = request.getParameter("id");
      int paperid = 0;
      if (oper == null) {
        oper = "";
      }
      if (name != null) {
        name = new String(name.getBytes("ISO-8859-1"), "utf-8").trim();
      }
      if (idcard != null) {
        idcard = new String(idcard.getBytes("ISO-8859-1"), "utf-8").trim();
      }
      if (duty != null) {
        duty = new String(duty.getBytes("ISO-8859-1"), "utf-8").trim();
      }
      if (dept != null) {
        dept = new String(dept.getBytes("ISO-8859-1"), "utf-8").trim();
      }
      if (dept != null) {
        area = new String(area.getBytes("ISO-8859-1"), "utf-8").trim();
      }
      if (papertypeid != null) {
        paperid = Integer.valueOf(papertypeid).intValue();
      }
      id = request.getParameter("id");

      Connection conn = (Connection)application.getAttribute("connect");
      if (conn == null)
      {
        conn = new Databases().getConn();
        application.setAttribute("connect", conn);
      }
      Statement st = conn.createStatement();

      String sqlsString = "";
      if (oper.equals("change"))
      {
        Examinee examinee = new Examinee(id, name, idcard, area, dept, paperid, duty);
        examinee.save(conn);
      }
      else if (oper.equals("bacthChange"))
      {
        String where = " where true ";
        where = where + (area.equals("%") ? "" : new StringBuilder(" and area='").append(area).append("' ").toString());
        where = where + (dept.equals("%") ? "" : new StringBuilder(" and dept='").append(dept).append("' ").toString());
        where = where + (duty.equals("%") ? "" : new StringBuilder(" and duty='").append(duty).append("' ").toString());
        ResultSet rs = st.executeQuery("select id FROM EXAMINEE " + where);
        while (rs.next())
        {
          Examinee examinee = Examinee.LoadExaminee(rs.getString(1), conn);
          examinee.setPaperTypeId(paperid);
          examinee.save(conn);
        }
      }
      else if (oper.equals("batchReset"))
      {
        ResultSet rs = conn.createStatement().executeQuery("select id FROM EXAMINEE ");
        while (rs.next())
        {
          Examinee examinee = Examinee.LoadExaminee(rs.getString(1), conn);
          examinee.setExamPaper(ExamPaper.loadMe(examinee, conn));
          examinee.save(conn);
        }
      }
      else if (oper.equals("del"))
      {
        st.execute("delete EXAMINEE where id='" + id + "'");
      }
      else if (oper.equals("bacthDel"))
      {
        String where = " where true ";
        where = where + (area.equals("%") ? "" : new StringBuilder(" and area='").append(area).append("' ").toString());
        where = where + (dept.equals("%") ? "" : new StringBuilder(" and dept='").append(dept).append("' ").toString());
        where = where + (duty.equals("%") ? "" : new StringBuilder(" and duty='").append(duty).append("' ").toString());
        sqlsString = "delete from EXAMINEE" + where;
        st.executeUpdate(sqlsString);
      }
      else if (oper.equals("add"))
      {
        Examinee examinee = new Examinee(id, name, idcard, area, dept, paperid, duty);
        examinee.save(conn);
      }
      else if (oper.equals("resetPaper"))
      {
        Examinee examinee = Examinee.LoadExaminee(id, conn);
        examinee.setExamPaper(ExamPaper.loadMe(examinee, conn));
        examinee.save(conn);
        HashMap<String, ExamPaper> paperMap = (HashMap)application
          .getAttribute("paperMap");
        if (paperMap != null) {
          paperMap.put(examinee.getId(), examinee.getExamPaper());
        }
      }
      String pageString = request.getParameter("page");
      String search = request.getParameter("search");
      String field = request.getParameter("field");
      String sql = "";String countsql = "";
      int pages = 0;int pageCount = 0;
      ResultSet rs = null;
      if (pageString != null)
      {
        pages = Integer.valueOf(pageString).intValue();
        sql = (String)session.getAttribute("sql");
        pageCount = ((Integer)session.getAttribute("pagecount")).intValue();
      }
      else
      {
        if ((field != null) && (search != null) && (search.length() > 0))
        {
          search = new String(search.getBytes("ISO-8859-1"), "utf-8").trim().replaceAll("'", "");
          sql = "select a.* ,b.papertypename from EXAMINEE a left join exampapertype b on a.papertypeid=b.id  where " + 
            field + " like '%" + search + "%' order by a.papertypeid";
          countsql = "select count(1) from EXAMINEE where name like '%" + search + "%'";
        }
        else
        {
          sql = "select a.* ,b.papertypename from EXAMINEE a left join exampapertype b on a.papertypeid=b.id order by a.papertypeid";
          countsql = "select count(1) from EXAMINEE";
        }
        rs = st.executeQuery(countsql);
        rs.next();
        pageCount = rs.getInt(1) / 10;
        session.setAttribute("sql", sql);
        session.setAttribute("pagecount", Integer.valueOf(pageCount));
      }
      st.execute(sql + " limit 10 offset 10*" + pageString);
      rs = st.getResultSet();

      RequestDispatcher dispatcher = request.getRequestDispatcher("head.jsp");
      dispatcher.include(request, response);
      out.write("\r\n");
      out.write("<script type=\"text/javascript\">\n");
      out.write("<!--\n");
      out.write("\tfunction isSubmit(){\r\n");
      out.write("\t\tif(confirm(\"确定要重置所有考生的试卷吗?\"))\r\n");
      out.write("\t\t\tlocation.href=\"adminExaminee.jsp?oper=batchReset\";\r\n");
      out.write("}\n");
      out.write("//-->\n");
      out.write("</script>\r\n");
      out.write("<div style=\"margin: 0 20px 20px 20px\">\r\n");
      out.write("<div class=block block-user id=block-user-0>\r\n");
      out.write("<h2><span class=w1><span class=w2>考生信息</span></span></h2>\r\n");
      out.write("<div class=content>\r\n");
      out.write("<div style=\"margin-top: 5px\" align=right>\r\n");
      out.write("<form action=adminExaminee.jsp method=post\r\n");
      out.write("\tstyle=\"margin: 0px; display: inline\" align=left><select\r\n");
      out.write("\tname=field>\r\n");
      out.write("\t<option value=\"name\" selected>按姓名</option>\r\n");
      out.write("\t<option value=\"dept\">按部门</option>\r\n");
      out.write("\t<option value=\"area\">按单位</option>\r\n");
      out.write("\t<option value=\"duty\">按职能</option>\r\n");
      out.write("</select>:<input type=text name=search><input type=image\r\n");
      out.write("\tsrc=\"../images/search.png\" alt=查找></form>\r\n");
      out.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=\"image\"\r\n");
      out.write("\tonfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"首页\" src=\"../images/first.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(0);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == 0 ? "DISABLED" : "");
      out.write(">&nbsp;&nbsp; <input type=\"image\"\r\n");
      out.write("\tonfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"上一页\"\r\n");
      out.write("\tsrc=\"../images/previoupage.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(pages - 1);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == 0 ? "DISABLED" : "");
      out.write(">&nbsp;&nbsp; <input type=\"image\"\r\n");
      out.write("\tonfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"下一页\"\r\n");
      out.write("\tsrc=\"../images/nextpage.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(pages + 1);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == pageCount ? "DISABLED" : "");
      out.write(">&nbsp;&nbsp; <input\r\n");
      out.write("\ttype=\"image\" onfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"末页\" src=\"../images/end.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(pageCount);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == pageCount ? "DISABLED" : "");
      out.write("></div>\r\n");
      out.write("<table CELLSPACING=0 class=admin width=100%>\r\n");
      out.write("\t<TR>\r\n");
      out.write("\t\t<th>考生编号</th>\r\n");
      out.write("\t\t<th>考生姓名</th>\r\n");
      out.write("\t\t<th>身份证</th>\r\n");
      out.write("\t\t<th>地区</th>\r\n");
      out.write("\t\t<th>部门</th>\r\n");
      out.write("\t\t<th>职务</th>\r\n");
      out.write("\t\t<th>试卷名称</th>\r\n");
      out.write("\t\t<th>试卷状态</th>\r\n");
      out.write("\t\t<th colspan=3>操作</th>\r\n");
      out.write("\t</TR>\r\n");
      out.write("\t");
      while (rs.next())
      {
        InputStream a = rs.getBinaryStream("exampaper");
        ExamPaper examPaper = null;
        if (a != null) {
          try
          {
            examPaper = (ExamPaper)new ObjectInputStream(a).readObject();
          }
          catch (Exception localException1) {}
        }
        out.write("<tr><td>" + 
          rs.getString("ID") + 
          "</td><td>" + 
          rs.getString("NAME") + 
          "</td><td>" + 
          rs.getString("IDCARD") + 
          "</td><td>" + 
          rs.getString("AREA") + 
          "</td><td>" + 
          rs.getString("DEPT") + 
          "</td><td>" + 
          rs.getString("duty") + 
          "</td><td>" + 
          rs.getString("papertypename") + 
          "</td><td>" + (

          examPaper.getStartTime() == 0L ? "未测试" : examPaper.isEnd() ? "成绩:" + examPaper.getScoring() : examPaper == null ? "未生成试卷" : "正在测试中") + 
          "</td><td><a href=adminExaminee.jsp?oper=resetPaper&id=" + rs.getString("ID") + 
          ">重置试卷</a></td><td><a href=adminExaminee.jsp?oper=changeShow&id=" + rs.getString("ID") + 
          "#add>修改</a></td><td><a href=adminExaminee.jsp?oper=del&id=" + rs.getString("ID") + 
          ">删除</a></td></tr>");
      }
      out.write("\r\n");
      out.write("</table>\r\n");
      out.write("<div style=\"margin-top: 5px\" align=right><input type=\"image\"\r\n");
      out.write("\tonfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"首页\" src=\"../images/first.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(0);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == 0 ? "DISABLED" : "");
      out.write(">&nbsp;&nbsp; <input type=\"image\"\r\n");
      out.write("\tonfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"上一页\"\r\n");
      out.write("\tsrc=\"../images/previoupage.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(pages - 1);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == 0 ? "DISABLED" : "");
      out.write(">&nbsp;&nbsp; <input type=\"image\"\r\n");
      out.write("\tonfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"下一页\"\r\n");
      out.write("\tsrc=\"../images/nextpage.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(pages + 1);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == pageCount ? "DISABLED" : "");
      out.write(">&nbsp;&nbsp; <input\r\n");
      out.write("\ttype=\"image\" onfocus=\"this.blur()\" unselectable=\"on\"\r\n");
      out.write("\tstyle=\"margin: 0px; padding: 0px\" alt=\"末页\" src=\"../images/end.png\"\r\n");
      out.write("\tonclick=\"location.href='adminExaminee.jsp?page=");
      out.print(pageCount);
      out.write("'\"\r\n");
      out.write("\t");
      out.print(pages == pageCount ? "DISABLED" : "");
      out.write("></div>\r\n");
      out.write("<div><input type=button onclick=\"isSubmit()\" value=\"所有人员试卷重置\">\r\n");
      out.write("</div>\r\n");
      out.write("</div>\r\n");
      out.write("</div>\r\n");
      out.write("<hr>\r\n");
      out.write("<a name=\"add\">\r\n");
      out.write("<div class=block block-user id=block-user-0>\r\n");
      out.write("<h2><span class=w1><span class=w2> ");
      if (oper.equals("changeShow"))
      {
        out.write("修改考生信息<button onclick='location.href=\"adminExaminee.jsp#add\"'>切换为新增</button>");
        st.execute("select * from EXAMINEE where ID='" + id + "' order by papertypeid");
        rs = st.getResultSet();
        if (rs.next())
        {
          name = rs.getString("NAME");
          idcard = rs.getString("IDCARD");
          area = rs.getString("AREA");
          dept = rs.getString("DEPT");
          duty = rs.getString("duty");
          paperid = rs.getInt("papertypeid");
        }
      }
      else
      {
        out.write("添加考生信息");
      }
      out.write(" </span></span></h2>\r\n");
      out.write("<div class=content>\r\n");
      out.write("<form class=admin action=adminExaminee.jsp method=\"post\"\r\n");
      out.write("\tonsubmit=\"return checkForm();\">\r\n");
      out.write("<table>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>考生编号:</td>\r\n");
      out.write("\t\t<td><input type=text id=\"id\" name=id\r\n");
      out.write("\t\t\t");
      out.print(oper.equals("changeShow") ? "value=" + id + " readonly" : "");
      out.write(" /></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>考生姓名:</td>\r\n");
      out.write("\t\t<td><input type=text id=\"name\" name=name\r\n");
      out.write("\t\t\t");
      out.print(oper.equals("changeShow") ? "value=" + name : "");
      out.write(" /></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>身&nbsp;份&nbsp;证:</td>\r\n");
      out.write("\t\t<td><input type=text id=idcard name=idcard\r\n");
      out.write("\t\t\t");
      out.print(oper.equals("changeShow") ? "value=" + idcard : "");
      out.write(" /></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>所在地区:</td>\r\n");
      out.write("\t\t<td><input type=text id=dept name=area\r\n");
      out.write("\t\t\t");
      out.print(oper.equals("changeShow") ? "value=" + area : "");
      out.write(" /></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>所在部门:</td>\r\n");
      out.write("\t\t<td><input type=text id=dept name=dept\r\n");
      out.write("\t\t\t");
      out.print(oper.equals("changeShow") ? "value=" + dept : "");
      out.write(" /></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>职&nbsp;&nbsp;&nbsp;&nbsp;务:</td>\r\n");
      out.write("\t\t<td><input type=text id=duty name=duty\r\n");
      out.write("\t\t\t");
      out.print(oper.equals("changeShow") ? "value=" + duty : "");
      out.write(" /></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td>试卷类型:</td>\r\n");
      out.write("\t\t<td><select name=papertypeid>\r\n");
      out.write("\t\t\t");

      st.execute("select id,papertypename from exampapertype");
      rs = st.getResultSet();
      while (rs.next())
      {
        String seleted = "";
        if (rs.getInt(1) == Integer.valueOf(paperid).intValue()) {
          seleted = "seleted";
        }
        out.write("<option value=\"" + rs.getInt(1) + "\" " + seleted + ">" + rs.getString(2) + "</option>)");
      }
      out.write("\r\n");
      out.write("\t\t</select></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td colspan=2 align=center><input type=hidden name=oper\r\n");
      out.write("\t\t\tvalue='");
      out.print(oper.equals("changeShow") ? "change" : "add");
      out.write("' /> <input\r\n");
      out.write("\t\t\ttype=submit value=\"确定 [O]\" /  accesskey=\"o\"></td>\r\n");
      out.write("\t\t</td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("</table>\r\n");
      out.write("</form>\r\n");
      out.write("</div>\r\n");
      out.write("</div>\r\n");
      out.write("<hr>\r\n");
      out.write("<a name=\"bacthAdd\"></a>\r\n");
      out.write("<div class=block block-user id=block-user-0>\r\n");
      out.write("<h2><span class=w1><span class=w2>批量导入</span></span></h2>\r\n");
      out.write("<div class=content>\r\n");
      out.write("<form action=\"bacthAddExaminee\" id=BacthAddExaminee\r\n");
      out.write("\tenctype=\"multipart/form-data\" method=\"post\"\r\n");
      out.write("\tonsubmit=\"return checkUpload();\"><input type=hidden name=oper\r\n");
      out.write("\tvalue='bacthAdd'> EXCEL文件:<input type=\"file\" name=\"file\"\r\n");
      out.write("\tsize=\"45\"> <input type=\"submit\" value=\"提 交[U]\" accesskey=\"u\"></form>\r\n");
      out.write("<p>具体格式请下载样本文档。&nbsp;&nbsp; <a href=\"../BacthAddExaminee.xls\">下载格式文档</a>\r\n");
      out.write("</p>\r\n");
      out.write("</div>\r\n");
      out.write("</div>\r\n");
      out.write("<hr>\r\n");
      out.write("<div class=block block-user id=block-user-0>\r\n");
      out.write("<h2><span class=w1><span class=w2>批量修改</span></span></h2>\r\n");
      out.write("<div class=content>\r\n");
      out.write("<form action=\"adminExaminee.jsp\"><input type=hidden name=oper\r\n");
      out.write("\tvalue='bacthChange'> 地区:<select name=area>\r\n");
      out.write("\t<option value=\"%\" selected>全部</option>\r\n");
      out.write("\t");

      st.execute("select distinct area from examinee");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(1) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp; 部门:<select name=dept>\r\n");
      out.write("\t<option value=\"%\" selected>全部</option>\r\n");
      out.write("\t");

      st.execute("select distinct dept from examinee");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(1) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp; 职务:<select name=duty>\r\n");
      out.write("\t<option value=\"%\" selected>全部</option>\r\n");
      out.write("\t");

      st.execute("select distinct duty from examinee");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(1) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp; 试卷类型:<select name=papertypeid>\r\n");
      out.write("\t");

      st.execute("select id,papertypename from exampapertype");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(2) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=\"submit\" value=\"提 交[C]\"\r\n");
      out.write("\taccesskey=\"c\"></form>\r\n");
      out.write("</div>\r\n");
      out.write("</div>\r\n");
      out.write("<hr>\r\n");
      out.write("<div class=block block-user id=block-user-0>\r\n");
      out.write("<h2><span class=w1><span class=w2>批量删除</span></span></h2>\r\n");
      out.write("<div class=content>\r\n");
      out.write("<form action=\"adminExaminee.jsp\" id=BacthDel method=\"post\"\r\n");
      out.write("\tonsubmit=\"return confirm('确定要全部删除指定的考生!')\"><input type=hidden\r\n");
      out.write("\tname=oper value='bacthDel'> 地区:<select name=area>\r\n");
      out.write("\t<br>\r\n");
      out.write("\t>\r\n");
      out.write("\t<option value=\"%\" selected>全部</option>\r\n");
      out.write("\t");

      st.execute("select distinct area from examinee");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(1) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 部门:<select name=dept>\r\n");
      out.write("\t<br>\r\n");
      out.write("\t>\r\n");
      out.write("\t<option value=\"%\" selected>全部</option>\r\n");
      out.write("\t");

      st.execute("select distinct dept from examinee");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(1) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 职务:<select name=duty>\r\n");
      out.write("\t<option value=\"%\" selected>全部</option>\r\n");
      out.write("\t");

      st.execute("select distinct duty from examinee");
      rs = st.getResultSet();
      while (rs.next()) {
        out.write("<option value=\"" + rs.getString(1) + "\">" + rs.getString(1) + "</option>)");
      }
      out.write("\r\n");
      out.write("</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=\"submit\" value=\"提 交[D]\"\r\n");
      out.write("\taccesskey=\"d\"></form>\r\n");
      out.write("</div>\r\n");
      out.write("</div></div>\r\n");
      out.write("</body>\r\n");
      out.write("<script>\r\n");
      out.write("function checkUpload() {\r\n");
      out.write("\t  var ext =BacthAddExaminee.file.value;\r\n");
      out.write("\t  ext = ext.substring(ext.length-4,ext.length);\r\n");
      out.write("\t  ext = ext.toLowerCase();\r\n");
      out.write("\t  if(ext != '.xls' || ext.length==null) {\r\n");
      out.write("\t\t \talert(\"你选择的文件不是.xls文件\"); \r\n");
      out.write("\t\t\treturn false;\r\n");
      out.write("\t  }else{\r\n");
      out.write("\t\t  \tshowWaiting();\r\n");
      out.write("\t\t \treturn true;\r\n");
      out.write("\t  }\r\n");
      out.write("}\r\n");
      out.write("function checkForm() {\r\n");
      out.write("\t  if(document.getElementById(\"id\").value.length==0||document.getElementById(\"name\").value.length==0||document.getElementById(\"idcard\").value.length==0||document.getElementById(\"dept\").value.length==0||document.getElementById(\"duty\").value.length==0){\r\n");
      out.write("\t\t  alert(\"有项目未输入必要的内容!\");\r\n");
      out.write("\t\t  return false;\r\n");
      out.write("\t  } else{\r\n");
      out.write("\t\t\t  return true;\r\n");
      out.write("\t  }\r\n");
      out.write("}\r\n");
      out.write("</script>\r\n");

      out.write("</html>\r\n");

      st.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      out.write("<script>alert('添加失败,可能你要添加的ID已经存在!')</script>");
      out.write("</html>\r\n");
    }
  }

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    doPost(request, response);
  }
}

4 个答案:

答案 0 :(得分:0)

如果部署展开的应用程序

表示您的代码是单独的.class文件,而不是.jar文件,

然后你可以替换单个文件。

问题是Java类加载器,特别是Tomcat类加载器,可能不会替换已经在内存中的类。

它不会被取代。

所以,你必须重启Tomcat。

答案 1 :(得分:0)

添加到Karibasappa的答案。 如果检查爆炸的war文件,WEB-INF文件夹中可能没有单独的类。您必须在WEB-INF中创建一个名为“classes”的文件夹。将您需要的类文件放入正确的包结构中(根据需要创建文件夹),然后重新启动tomcat。

答案 2 :(得分:0)

您将无法自行编译单个文件。该文件有许多依赖项(导入和使用许多其他类)。您可以做的是将所有类文件作为AdminExaminee类所属的同一项目的一部分,然后: 1.使用所有类文件在eclipse中创建项目(在编译之后) 2.修改所需的类文件(在您的情况下为AdminExaminee) 3.编译项目 4.用新的类文件

替换旧的类文件

这可能不是可用的最佳解决方案,但肯定会有效。我过去遇到过类似的问题,并且使用了相同的技术。

答案 3 :(得分:0)

由于您没有依赖项[导入的文件],因此可能无法使用javac在外部编译该类。您必须创建一个新项目,反编译所有类并添加为java文件,进行更改并进行构建。最好是部署整个战争,而不是改变爆炸战争。