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


Java StringUtils.containsWhitespace方法代碼示例

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


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

示例1: preHandle

import org.springframework.util.StringUtils; //導入方法依賴的package包/類
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
	
       String emailAddress = request.getParameter("email");
       String password = request.getParameter("password");
       
       if(StringUtils.isEmpty(emailAddress) || StringUtils.containsWhitespace(emailAddress) ||
       		StringUtils.isEmpty(password) || StringUtils.containsWhitespace(password)) {
       	throw new Exception("Invalid Email Address or Password. Please try again.");
       }
       
       return true;
}
 
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:14,代碼來源:SignupInterceptor.java

示例2: setAsText

import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
 * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2.
 * Null or the empty string means that the method is non transactional.
 * @see java.beans.PropertyEditor#setAsText(java.lang.String)
 */
@Override
public void setAsText(String text) throws IllegalArgumentException {
	if (StringUtils.hasLength(text)) {
		// tokenize it with ","
		String[] tokens = StringUtils.commaDelimitedListToStringArray(text);
		RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute();
		for (int i = 0; i < tokens.length; i++) {
			// Trim leading and trailing whitespace.
			String token = StringUtils.trimWhitespace(tokens[i].trim());
			// Check whether token contains illegal whitespace within text.
			if (StringUtils.containsWhitespace(token)) {
				throw new IllegalArgumentException(
						"Transaction attribute token contains illegal whitespace: [" + token + "]");
			}
			// Check token type.
			if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
				attr.setPropagationBehaviorName(token);
			}
			else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
				attr.setIsolationLevelName(token);
			}
			else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
				String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
				attr.setTimeout(Integer.parseInt(value));
			}
			else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
				attr.setReadOnly(true);
			}
			else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
				attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1)));
			}
			else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
				attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1)));
			}
			else {
				throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]");
			}
		}
		setValue(attr);
	}
	else {
		setValue(null);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:50,代碼來源:TransactionAttributeEditor.java


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