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


Java WebUtils.SUBMIT_IMAGE_SUFFIXES屬性代碼示例

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


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

示例1: getTargetPage

/**
 * Return the target page specified in the request.
 * @param request current portlet request
 * @param paramPrefix the parameter prefix to check for
 * (e.g. "_target" for parameters like "_target1" or "_target2")
 * @param currentPage the current page, to be returned as fallback
 * if no target page specified
 * @return the page specified in the request, or current page if not found
 */
public static int getTargetPage(PortletRequest request, String paramPrefix, int currentPage) {
	Enumeration<String> paramNames = request.getParameterNames();
	while (paramNames.hasMoreElements()) {
		String paramName = paramNames.nextElement();
		if (paramName.startsWith(paramPrefix)) {
			for (int i = 0; i < WebUtils.SUBMIT_IMAGE_SUFFIXES.length; i++) {
				String suffix = WebUtils.SUBMIT_IMAGE_SUFFIXES[i];
				if (paramName.endsWith(suffix)) {
					paramName = paramName.substring(0, paramName.length() - suffix.length());
				}
			}
			return Integer.parseInt(paramName.substring(paramPrefix.length()));
		}
	}
	return currentPage;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:25,代碼來源:PortletUtils.java

示例2: getSubmitParameter

/**
 * Return the full name of a specific input type="submit" parameter
 * if it was sent in the request, either via a button (directly with name)
 * or via an image (name + ".x" or name + ".y").
 * @param request current portlet request
 * @param name name of the parameter
 * @return the actual parameter name with suffix if needed - null if not present
 * @see org.springframework.web.util.WebUtils#SUBMIT_IMAGE_SUFFIXES
 */
public static String getSubmitParameter(PortletRequest request, String name) {
	Assert.notNull(request, "Request must not be null");
	if (request.getParameter(name) != null) {
		return name;
	}
	for (int i = 0; i < WebUtils.SUBMIT_IMAGE_SUFFIXES.length; i++) {
		String suffix = WebUtils.SUBMIT_IMAGE_SUFFIXES[i];
		String parameter = name + suffix;
		if (request.getParameter(parameter) != null) {
			return parameter;
		}
	}
	return null;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:23,代碼來源:PortletUtils.java

示例3: testGetSubmitParameterWithPrefixedParameterMatch

@Test
public void testGetSubmitParameterWithPrefixedParameterMatch() throws Exception {
	final String bareParameterName = "William";
	final String targetParameterName = bareParameterName + WebUtils.SUBMIT_IMAGE_SUFFIXES[0];
	MockPortletRequest request = new MockPortletRequest();
	request.setParameter(targetParameterName, "Baskerville");
	request.setParameter("Adso", "Melk");
	String submitParameter = PortletUtils.getSubmitParameter(request, bareParameterName);
	assertNotNull(submitParameter);
	assertEquals(targetParameterName, submitParameter);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:11,代碼來源:PortletUtilsTests.java

示例4: testHasSubmitParameterWithPrefixedParameterMatch

@Test
public void testHasSubmitParameterWithPrefixedParameterMatch() throws Exception {
	final String bareParameterName = "William";
	final String targetParameterName = bareParameterName + WebUtils.SUBMIT_IMAGE_SUFFIXES[0];
	MockPortletRequest request = new MockPortletRequest();
	request.setParameter(targetParameterName, "Baskerville");
	request.setParameter("Adso", "Melk");
	assertTrue(PortletUtils.hasSubmitParameter(request, bareParameterName));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:9,代碼來源:PortletUtilsTests.java


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