public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ListForm aWebForm = (ListForm) actionForm; if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值 Deal.doList(aWebForm, request, response); // 查询处理 return actionMapping.getInputForward(); } else { String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法"; if (aWebForm.getMethod().equals("jgys_submit")) { // 修改 Deal.doList(aWebForm, request, response); // 查询处理 Deal.doJgys_submit(aWebForm, request, response); sMessage = "确定竣工验收报告,并提交到工程结算处理成功"; } CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面 mMessage.setMessage(sMessage); // 默认为"处理成功!" String[] button = {"关闭"}; // 按钮数组 String[] onclick = {"parent.window.close()"}; // 按钮响应事件 mMessage.setButtonName(button); mMessage.setOnClickFunc(onclick); request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage); // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message) return actionMapping.findForward("message"); } }
/** * 响应页面提交 * * @param actionMapping ActionMapping 这个 Action 的配置信息 * @param actionForm ActionForm 用户提交的表单数据 * @param request HttpServletRequest 当前的 HTTP 请求对象 * @param response HttpServletResponse 当前的 HTTP 响应对象 * @return ActionForward 请求转发路径 * @throws Exception */ public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { QueryForm aWebForm = (QueryForm) actionForm; Deal.doQuery(aWebForm, request, response); // 查询处理 return actionMapping.getInputForward(); }
/** * Handle the Exception. Return the ActionForward instance (if any) returned by the called * ExceptionHandler. * * @param ex The exception to handle * @param ae The ExceptionConfig corresponding to the exception * @param mapping The ActionMapping we are processing * @param formInstance The ActionForm we are processing * @param request The servlet request we are processing * @param response The servlet response we are creating * @return The <code>ActionForward</code> instance (if any) returned by the called <code> * ExceptionHandler</code>. * @throws ServletException if a servlet exception occurs * @since Struts 1.1 */ public ActionForward execute( Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException { LOG.debug("ExceptionHandler executing for exception " + ex); ActionForward forward; ActionMessage error; String property; // Build the forward from the exception mapping if it exists // or from the form input if (ae.getPath() != null) { forward = new ActionForward(ae.getPath()); } else { forward = mapping.getInputForward(); } // Figure out the error if (ex instanceof ModuleException) { error = ((ModuleException) ex).getActionMessage(); property = ((ModuleException) ex).getProperty(); } else { error = new ActionMessage(ae.getKey(), ex.getMessage()); property = error.getKey(); } this.logException(ex); // Store the exception request.setAttribute(Globals.EXCEPTION_KEY, ex); this.storeException(request, property, error, forward, ae.getScope()); if (!response.isCommitted()) { return forward; } LOG.debug( "Response is already committed, so forwarding will not work." + " Attempt alternate handling."); if (!silent(ae)) { handleCommittedResponse(ex, ae, mapping, formInstance, request, response, forward); } else { LOG.warn( "ExceptionHandler configured with " + SILENT_IF_COMMITTED + " and response is committed.", ex); } return null; }
/** * 响应页面提交 * * @param actionMapping ActionMapping这个 Action 的配置信息 * @param actionForm ActionForm 用户提交的表单数据 * @param request HttpServletRequest当前的 HTTP 请求对象 * @param response HttpServletResponse当前的 HTTP 响应对象 * @return ActionForward 提交到查询页面 * @throws Exception */ public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { EditForm aWebForm = (EditForm) actionForm; Deal.setEditDefault(aWebForm, request, response); // 设置进入增加页面的初始值 if (request.getParameter("print") == null) { return actionMapping.getInputForward(); } else { return actionMapping.findForward("print"); } }
/** * 响应页面提交 * * @param actionMapping ActionMapping这个 Action 的配置信息 * @param actionForm ActionForm 用户提交的表单数据 * @param request HttpServletRequest当前的 HTTP 请求对象 * @param response HttpServletResponse当前的 HTTP 响应对象 * @return ActionForward 提交到查询页面 * @throws Exception */ public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { EditForm aWebForm = (EditForm) actionForm; if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值 Deal.setEditDefault(aWebForm, request, response); // 设置进入增加页面的初始值 return actionMapping.getInputForward(); } else { String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法"; String[] button; // 按钮数组 String[] onclick; // 按钮响应事件 if (aWebForm.getMethod().equals("edit")) { // 修改 Deal.doDHHFEdit(aWebForm, request, response); // 处理修改 sMessage = mModuleName + "修改处理成功"; button = new String[] {"关闭"}; // 按钮数组 onclick = new String[] {"parent.window.close()"}; // 按钮响应事件 } else if (aWebForm.getMethod().equals("add")) { // 修改 Deal.doDHHFAdd(aWebForm, request, response); // 处理修改 sMessage = mModuleName + "增加处理成功"; button = new String[] {"关闭"}; // 按钮数组 onclick = new String[] {"parent.window.close()"}; // 按钮响应事件 } else if (aWebForm.getMethod().equals("del")) { // 删除 Deal.doDHHFDelete(aWebForm, request, response); // 处理删除 sMessage = mModuleName + "删除处理成功"; button = new String[] {"关闭"}; // 按钮数组 onclick = new String[] {"parent.window.close()"}; // 按钮响应事件 } else { // 未能找到 " + aWebForm.getMethod() + " 对应的处理方法 button = new String[] {"关闭"}; // 按钮数组 onclick = new String[] {"parent.window.close()"}; // 按钮响应事件 } CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面 mMessage.setMessage(sMessage); // 默认为"处理成功!" mMessage.setButtonName(button); mMessage.setOnClickFunc(onclick); request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage); // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message) return actionMapping.findForward("message"); } }