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

📄 addinformaction.java

📁 教师办公管理系统
💻 JAVA
字号:
package to.view.Action;
import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import java.io.IOException;
import javax.servlet.ServletException;
import to.model.Inform.InformBean;
import to.model.Inform.InformItem;

public class AddInformAction extends Action 
{
  /**
   * This is the main action called from the Struts framework.
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   * @throws javax.servlet.ServletException
   * @throws java.io.IOException
   * @return 
   */
  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
  {
    
    String InformT=request.getParameter("InformT").trim();
    String InformC=request.getParameter("InformC").trim();
    String AddT=request.getParameter("AddT").trim();
    String EndT=request.getParameter("EndT").trim();
    String Promulgator=request.getParameter("Promulgator").trim();
    int Embracer=Integer.parseInt(request.getParameter("Embracer").trim());
    
    if(InformT==null||InformT.length()<1)
    {
       request.setAttribute("question","通知标题不能为空!");
       return mapping.findForward("failure");
    }
    else if(InformC==null||InformC.length()<1)
    {
      request.setAttribute("question","通知内容不能为空!");
      return mapping.findForward("failure");
    }
    else if(AddT==null||AddT.length()<1)
    {
      request.setAttribute("question","发布日期不能为空!");
      return mapping.findForward("failure");
    }
    else if(EndT==null||EndT.length()<1)
    {
      request.setAttribute("question","通知有效日期不能为空!");
      return mapping.findForward("failure");
    }
    else if(Promulgator==null||Promulgator.length()<1)
    {
      request.setAttribute("question","发布人不能为空!");
      return mapping.findForward("failure");
    }
    
    
    String aa=EndT.substring(0,4);
    String bb=EndT.substring(5,7);
    String cc=EndT.substring(8,10);
    
    String dd=AddT.substring(0,4);
    String ee=AddT.substring(5,7);
    String ff=AddT.substring(8,10);
    
    int tempEndT=Integer.parseInt(aa+bb+cc);
    int tempAddT=Integer.parseInt(dd+ee+ff);
    
    if(tempEndT<tempAddT)
    {
       request.setAttribute("question","有效期年限输入有误");
       return mapping.findForward("failure");
    }
    
    
    
    //if(aa<dd)
    //{
       //request.setAttribute("question","有效期年限输入有误");
       //return mapping.findForward("failure");
    //}
    //else if(bb<ee)
    //{
       //request.setAttribute("question","有效期年限输入有误");
       //return mapping.findForward("failure");
    //}
    //else if(cc<ff)
    //{
      //request.setAttribute("question","有效期年限输入有误");
      //return mapping.findForward("failure");
    //}
    

    InformBean ib=new InformBean();
    InformItem ii=new InformItem();
      
    ii.setInformT(InformT);
    ii.setInformC(InformC);
    ii.setAddT(AddT);
    ii.setEndT(EndT);
    ii.setPromulgator(Promulgator);
    ii.setEmbracer(Embracer);
      
    if(ib.insertInform(ii).equals("添加成功"))
    {
      ib.insertTempInform(ii);
      request.setAttribute("message","通知发布成功!");
      return mapping.findForward("success");
    }
    request.setAttribute("question","通知发布失败!");
    return mapping.findForward("failure");
  }
}

⌨️ 快捷键说明

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