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


Java StringUtils.pathEquals方法代碼示例

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


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

示例1: setWebAppRootSystemProperty

import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
 * Set a system property to the web application root directory.
 * The key of the system property can be defined with the "webAppRootKey"
 * context-param in {@code web.xml}. Default is "webapp.root".
 * <p>Can be used for tools that support substition with {@code System.getProperty}
 * values, like log4j's "${key}" syntax within log file locations.
 * @param servletContext the servlet context of the web application
 * @throws IllegalStateException if the system property is already set,
 * or if the WAR file is not expanded
 * @see #WEB_APP_ROOT_KEY_PARAM
 * @see #DEFAULT_WEB_APP_ROOT_KEY
 * @see WebAppRootListener
 * @see Log4jWebConfigurer
 */
public static void setWebAppRootSystemProperty(ServletContext servletContext) throws IllegalStateException {
	Assert.notNull(servletContext, "ServletContext must not be null");
	String root = servletContext.getRealPath("/");
	if (root == null) {
		throw new IllegalStateException(
			"Cannot set web app root system property when WAR file is not expanded");
	}
	String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
	String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
	String oldValue = System.getProperty(key);
	if (oldValue != null && !StringUtils.pathEquals(oldValue, root)) {
		throw new IllegalStateException(
			"Web app root system property already set to different value: '" +
			key + "' = [" + oldValue + "] instead of [" + root + "] - " +
			"Choose unique values for the 'webAppRootKey' context-param in your web.xml files!");
	}
	System.setProperty(key, root);
	servletContext.log("Set web app root system property: '" + key + "' = [" + root + "]");
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:WebUtils.java

示例2: register

import org.springframework.util.StringUtils; //導入方法依賴的package包/類
@RequestMapping(value = "/register",method = RequestMethod.POST)
@ApiOperation(value = "Register user")
public ResponseEntity<?>  register(@RequestBody AuthRequest authRequest) throws AuthenticationException{
    logger.debug("Register with \r\n"+authRequest.toString());
    if (authRequest==null || StringUtils.isEmpty(authRequest.getUsername())){
        throw new UsernameNotFoundException("Username is empty.");
    }
    String captcha = captchaService.getCachedCaptcha(authRequest.getUsername());
    if (StringUtils.isEmpty(captcha)){
        throw new BadCaptchaException("Captcha is empty");
    }
    if (!StringUtils.pathEquals(captcha,authRequest.getCaptcha())){
        throw new BadCaptchaException("Bad captcha");
    }
    if (StringUtils.isEmpty(authRequest.getPassword())){
        throw new BadCredentialsException("Bad credentials");
    }
    if (userService.isUserExist(authRequest.getUsername())){
        throw new UserExistException("User has existed");
    }
    boolean result = userService.createUser(authRequest.getUsername(),authRequest.getPassword());
    if (result){
        return ResponseEntity.ok(AuthResponse.success());
    } else {
        logger.warn("Create user failed.");
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body(AuthResponse.failure("Create user failed"));
    }
}
 
開發者ID:carycui,項目名稱:parkingcloud,代碼行數:30,代碼來源:AuthController.java


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