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