本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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));
}