当前位置: 首页>>代码示例>>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;未经允许,请勿转载。