Parameter.java
上传用户:ycdfsj258
上传日期:2022-08-04
资源大小:1094k
文件大小:2k
源码类别:

图形图象

开发平台:

Java

  1. package com.action;
  2. import org.apache.struts.action.ActionMapping;
  3. import org.apache.struts.action.ActionForm;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.apache.struts.action.ActionForward;
  7. import com.actionForm.ParameterForm;
  8. import com.dao.ParameterDAO;
  9. import org.apache.struts.action.Action;
  10. public class Parameter extends Action {
  11.     ParameterDAO parameterDAO=null;
  12.     public Parameter(){
  13.         parameterDAO=new ParameterDAO();
  14.     }
  15.     public ActionForward perform(ActionMapping mapping, ActionForm form,
  16.                                  HttpServletRequest request,
  17.                                  HttpServletResponse response) {
  18.         ParameterForm parameterForm=(ParameterForm) form;
  19.         String str=request.getParameter("action");
  20.         if("parameterQuery".equals(str)){
  21.             return parameterModifyQuery(mapping,form,request,response);
  22.         }else if("parameterModify".equals(str)){
  23.             return parameterModify(mapping,form,request,response);
  24.         }
  25.         request.setAttribute("error","您的操作有误!");
  26.         return mapping.findForward("error");
  27.     }
  28.     private ActionForward parameterModify(ActionMapping mapping, ActionForm form,
  29.                                  HttpServletRequest request,
  30.                                  HttpServletResponse response
  31. ){
  32.         ParameterForm parameterForm = (ParameterForm) form;
  33.         parameterForm.setId(parameterForm.getId());
  34.         parameterForm.setCost(parameterForm.getCost());
  35.         parameterForm.setValidity(parameterForm.getValidity());
  36.         int ret = parameterDAO.update(parameterForm);
  37.         if (ret ==0) {
  38.             request.setAttribute("error", "参数设置信息修改失败!");
  39.             return mapping.findForward("error");
  40.         } else {
  41.             return mapping.findForward("parametermodify");
  42.         }
  43.     }
  44.     private ActionForward parameterModifyQuery(ActionMapping mapping, ActionForm form,
  45.                                  HttpServletRequest request,
  46.                                  HttpServletResponse response
  47. ){
  48.         request.setAttribute("parameterModifyif",parameterDAO.query());
  49.         return mapping.findForward("parametermodifyQuery");
  50.     }
  51. }