當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionErrors.get方法代碼示例

本文整理匯總了Java中org.apache.struts.action.ActionErrors.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionErrors.get方法的具體用法?Java ActionErrors.get怎麽用?Java ActionErrors.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.struts.action.ActionErrors的用法示例。


在下文中一共展示了ActionErrors.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
 *  Processes the DDS web service request by forwarding to the appropriate
 *  corresponding JSP page for rendering.
 *
 * @param  mapping        The ActionMapping used to select this instance
 * @param  request        The HTTP request we are processing
 * @param  response       The HTTP response we are creating
 * @param  form           The ActionForm for the given page
 * @return                The ActionForward instance describing where and how
 *      control should be forwarded
 * @exception  Exception  If error.
 */
public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		 throws Exception {
	/*
	 *  Design note:
	 *  Only one instance of this class gets created for the app and shared by
	 *  all threads. To be thread-safe, use only local variables, not instance
	 *  variables (the JVM will handle these properly using the stack). Pass
	 *  all variables via method signatures rather than instance vars.
	 */
	RecommenderForm recForm = null;
	try {

		recForm = (RecommenderForm) form;
		
		// how to notify of configuration errrors??
		ActionErrors errors = initializeFromContext (mapping, request);
		if (!errors.isEmpty()) {
			List errorList = new ArrayList ();
			for (Iterator i=errors.get();i.hasNext();) {
				ActionError err = (ActionError)i.next();
				prtln ("\t" + err.toString());
				errorList.add (err.toString());
			}
			recForm.setErrorList(errorList);
			prtln ("initializeFromContext errors (" + errors.size() + ")");
			logErrors (errorList);
			return  mapping.findForward("dcsservices.error");
		}
		
		// Grab the DDS service request verb:
		String verb = request.getParameter("verb");
		if (verb == null) {
			recForm.setErrorMsg("The verb argument is required. Please indicate the request verb");
			return (mapping.findForward("dcsservices.error"));
		}

		// Handle put record request:
		else if (verb.equals(RECOMMEND_RESOURCE)) {
			return doRecommendResource(request, response, recForm, mapping);
		}	
		// Handle export request:
			else if (verb.equals(RECOMMEND_COLLECTION)) {
			return doRecommendCollection(request, response, recForm, mapping);
		}
		// The verb is not valid for the DDS web service
		else {
			recForm.setErrorMsg("The verb argument '" + verb + "' is not valid");
			return (mapping.findForward("dcsservices.error"));
		}
	} catch (NullPointerException npe) {
		prtln("RecommenderAction caught exception. " + npe);
		npe.printStackTrace();
		recForm.setErrorMsg("There was an internal error by the server: " + npe);
		return (mapping.findForward("dcsservices.error"));
	} catch (Throwable e) {
		prtln("RecommenderAction caught exception. " + e);
		e.printStackTrace();
		recForm.setErrorMsg("There was an internal error by the server: " + e);
		return (mapping.findForward("dcsservices.error"));
	}
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:78,代碼來源:RecommenderAction.java


注:本文中的org.apache.struts.action.ActionErrors.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。