当前位置: 首页>>代码示例>>Java>>正文


Java MethodArgumentTypeMismatchException类代码示例

本文整理汇总了Java中org.springframework.web.method.annotation.MethodArgumentTypeMismatchException的典型用法代码示例。如果您正苦于以下问题:Java MethodArgumentTypeMismatchException类的具体用法?Java MethodArgumentTypeMismatchException怎么用?Java MethodArgumentTypeMismatchException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodArgumentTypeMismatchException类属于org.springframework.web.method.annotation包,在下文中一共展示了MethodArgumentTypeMismatchException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onClientGenericBadRequest

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Client did not formulate a correct request.
 * Log the exception message at warn level and stack trace as trace level.
 * Return response status HttpStatus.BAD_REQUEST (400).
 */
@ExceptionHandler({
	MissingServletRequestParameterException.class,
	MethodArgumentTypeMismatchException.class,
	InvalidStreamDefinitionException.class
})
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public VndErrors onClientGenericBadRequest(Exception e) {
	String logref = logWarnLevelExceptionMessage(e);
	if (logger.isTraceEnabled()) {
		logTraceLevelStrackTrace(e);
	}
	String msg = getExceptionMessage(e);
	return new VndErrors(logref, msg);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:21,代码来源:RestControllerAdvice.java

示例2: handleMethodArgumentTypeMismatch

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
@ExceptionHandler({ MethodArgumentTypeMismatchException.class })
public ResponseEntity<Object> handleMethodArgumentTypeMismatch(final MethodArgumentTypeMismatchException ex, final WebRequest request) {
	logger.info(ex.getClass().getName());
	//
	final String error = ex.getName() + " should be of type " + ex.getRequiredType().getName();

	final AitException AitException = new AitException(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error);
	return new ResponseEntity<Object>(AitException, new HttpHeaders(), AitException.getStatus());
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:10,代码来源:AitRestExceptionHandler.java

示例3: BaseExceptionHandler

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
public BaseExceptionHandler(final Logger log) {
    this.log = log;

    registerMapping(
            MissingServletRequestParameterException.class,
            "MISSING_PARAMETER",
            "Missing request parameter",
            BAD_REQUEST);
    registerMapping(
            MethodArgumentTypeMismatchException.class,
            "ARGUMENT_TYPE_MISMATCH",
            "Argument type mismatch",
            BAD_REQUEST);
    registerMapping(
            HttpRequestMethodNotSupportedException.class,
            "METHOD_NOT_SUPPORTED",
            "HTTP method not supported",
            METHOD_NOT_ALLOWED);
    registerMapping(
            ServletRequestBindingException.class,
            "MISSING_HEADER",
            "Missing header in request",
            BAD_REQUEST);
}
 
开发者ID:nielsutrecht,项目名称:controller-advice-exception-handler,代码行数:25,代码来源:BaseExceptionHandler.java

示例4: testIllegalOfferId

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal offer id.
 */
@Test
public void testIllegalOfferId() {	
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("offer_id", "asdf")
	.when()
		.get(OFFERPHOTO_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:19,代码来源:OfferPhotoRestControllerIT.java

示例5: testIllegalRestaurantId

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal restaurant id.
 */
@Test
public void testIllegalRestaurantId() {	
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("restaurant_id", "asdf")
	.when()
		.get(OFFER_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:19,代码来源:OfferRestControllerIT.java

示例6: testIllegalLatitude

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal latitude.
 */
@Test
public void testIllegalLatitude() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("radius", 0)
		.param("longitude", -1)
		.param("latitude", "asdf")
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:21,代码来源:RestaurantRestControllerIT.java

示例7: testIllegalLongitude

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal longitude.
 */
@Test
public void testIllegalLongitude() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("radius", 0)
		.param("longitude", "asdf")
		.param("latitude", -1)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:21,代码来源:RestaurantRestControllerIT.java

示例8: testIllegalRadius

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal radius.
 */
@Test
public void testIllegalRadius() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("radius", "asdf")
		.param("longitude", -1)
		.param("latitude", -1)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:21,代码来源:RestaurantRestControllerIT.java

示例9: tesLatitudeEmpty

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test empty latitude.
 */
@Test
public void tesLatitudeEmpty() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("radius", 0)
		.param("longitude", -1)
		.param("latitude", "")
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:21,代码来源:RestaurantRestControllerIT.java

示例10: testLongitudeEmpty

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test empty longitude.
 */
@Test
public void testLongitudeEmpty() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("radius", 0)
		.param("longitude", "")
		.param("latitude", -1)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:21,代码来源:RestaurantRestControllerIT.java

示例11: testRadiusEmpty

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test empty radius.
 */
@Test
public void testRadiusEmpty() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.param("radius", "")
		.param("longitude", -1)
		.param("latitude", -1)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:21,代码来源:RestaurantRestControllerIT.java

示例12: testIllegalLatitudeAuthorizedCall

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal latitude.
 */
@Test
public void testIllegalLatitudeAuthorizedCall() {
	
	User user = getUserWithUserTypeKunde();
	userRepository.save(user);
	String authString = user.getUsername() + ":" + user.getPasswordconfirm();
	byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
	String encodedString = new String(base64Encoded);
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.header("Authorization", "Basic " + encodedString)
		.param("radius", 0)
		.param("longitude", -1)
		.param("latitude", "asdf")
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:28,代码来源:RestaurantRestControllerIT.java

示例13: testIllegalLongitudeAuthorizedCall

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal longitude.
 */
@Test
public void testIllegalLongitudeAuthorizedCall() {
	
	User user = getUserWithUserTypeKunde();
	userRepository.save(user);
	String authString = user.getUsername() + ":" + user.getPasswordconfirm();
	byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
	String encodedString = new String(base64Encoded);
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.header("Authorization", "Basic " + encodedString)
		.param("radius", 0)
		.param("longitude", "asdf")
		.param("latitude", -1)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:28,代码来源:RestaurantRestControllerIT.java

示例14: testIllegalRadiusAuthorizedCall

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test illegal radius.
 */
@Test
public void testIllegalRadiusAuthorizedCall() {
	
	User user = getUserWithUserTypeKunde();
	userRepository.save(user);
	String authString = user.getUsername() + ":" + user.getPasswordconfirm();
	byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
	String encodedString = new String(base64Encoded);
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.header("Authorization", "Basic " + encodedString)
		.param("radius", "asdf")
		.param("longitude", -1)
		.param("latitude", -1)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:28,代码来源:RestaurantRestControllerIT.java

示例15: testLatitudeEmptyAuthorizedCall

import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; //导入依赖的package包/类
/**
 * Test empty latitude.
 */
@Test
public void testLatitudeEmptyAuthorizedCall() {
	
	User user = getUserWithUserTypeKunde();
	userRepository.save(user);
	String authString = user.getUsername() + ":" + user.getPasswordconfirm();
	byte[] base64Encoded = Base64.getEncoder().encode(authString.getBytes());
	String encodedString = new String(base64Encoded);
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

	RestAssured
	.given()
		.header("Authorization", "Basic " + encodedString)
		.param("radius", 0)
		.param("longitude", -1)
		.param("latitude", "")
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MethodArgumentTypeMismatchException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:28,代码来源:RestaurantRestControllerIT.java


注:本文中的org.springframework.web.method.annotation.MethodArgumentTypeMismatchException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。