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


Java MissingServletRequestParameterException类代码示例

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


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

示例1: processMissingServletRequestParameterError

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public FieldErrorVM processMissingServletRequestParameterError(MissingServletRequestParameterException ex) {
    FieldErrorVM dto = new FieldErrorVM(ErrorConstants.ERR_VALIDATION, translate(ErrorConstants.ERR_VALIDATION));
    dto.add(ex.getParameterType(), ex.getParameterName(), ex.getLocalizedMessage());
    return dto;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:8,代码来源:ExceptionTranslator.java

示例2: handleMissingAndMalformedParametersValues

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@ExceptionHandler({
    InvalidArgumentException.class,
    MalformedTemplateException.class,
    MissingServletRequestParameterException.class,
    MissingServletRequestPartException.class,
    ServletRequestBindingException.class })
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
@ResponseBody
public void handleMissingAndMalformedParametersValues(Exception exception) {
    log.error("Input parameters were missing/malformed:", exception);
}
 
开发者ID:hmcts,项目名称:cmc-pdf-service,代码行数:12,代码来源:ExceptionHandling.java

示例3: paramMissErrorHandler

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Map<String,String> paramMissErrorHandler(MissingServletRequestParameterException e) throws Exception {
    Map error = new HashMap();
    error.put("error","参数" + e.getParameterName() + "不能为空");
    return error;
}
 
开发者ID:Nbsaw,项目名称:miaohu,代码行数:8,代码来源:GlobalExceptionAdvice.java

示例4: onClientGenericBadRequest

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的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

示例5: handleMissingValue

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@Override
protected void handleMissingValue(String name, MethodParameter parameter, NativeWebRequest request)
        throws Exception {

    HttpServletRequest servletRequest = request.getNativeRequest(HttpServletRequest.class);
    if (MultipartResolutionDelegate.isMultipartArgument(parameter)) {
        if (!MultipartResolutionDelegate.isMultipartRequest(servletRequest)) {
            throw new MultipartException("Current request is not a multipart request");
        } else {
            throw new MissingServletRequestPartException(name);
        }
    } else {
        throw new MissingServletRequestParameterException(name,
                parameter.getNestedParameterType().getSimpleName());
    }
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:17,代码来源:WxArgumentResolver.java

示例6: BaseExceptionHandler

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的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

示例7: testRequiredParameterMissing

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
/**
 * Test required parameter missing.
 */
@Test
public void testRequiredParameterMissing() {
	
	RestAssured
	.registerParser("text/plain", Parser.TEXT);

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

示例8: testRequiredParameterMissingAuthorizedCall

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
/**
 * Test required parameter missing.
 */
@Test
public void testRequiredParameterMissingAuthorizedCall() {
	
	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)
	.when()
		.get(RESTAURANT_API)
	.then()
		.statusCode(200)
		.body(Matchers.containsString(MissingServletRequestParameterException.class.toString()));
}
 
开发者ID:andju,项目名称:findlunch,代码行数:27,代码来源:RestaurantRestControllerIT.java

示例9: handleUncaughtException

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@ExceptionHandler(Exception.class)
public void handleUncaughtException(Exception ex, WebRequest request, HttpServletResponse response) throws IOException {
	if (ex instanceof HttpMediaTypeNotAcceptableException) {
		response.sendError(HttpStatus.NOT_ACCEPTABLE.value());
	} else if (ex instanceof HttpMessageNotReadableException
			|| ex instanceof MissingServletRequestParameterException
			|| ex instanceof HttpMediaTypeNotSupportedException) {
		response.sendError(HttpStatus.BAD_REQUEST.value(), ex.getLocalizedMessage().substring(0, ex.getLocalizedMessage().indexOf("\n")));
	} else {
		int hashValue = response.hashCode();
		//Note: we are giving the user a generic message.  
		//Server logs can be used to troubleshoot problems.
		String msgText = "Something bad happened. Contact us with Reference Number: " + hashValue;
		LOG.error(msgText, ex);
		response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(), msgText);
	}
}
 
开发者ID:NWQMC,项目名称:WQP-WQX-Services,代码行数:18,代码来源:GlobalDefaultExceptionHandler.java

示例10: preHandle

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@Override
public boolean preHandle(HttpServletRequest request,
		HttpServletResponse response, Object handler) throws Exception
{
	// see if a handler is of the type that requires form context
	if (handler instanceof FormContextRequired)
	{
		FormContextRequired controller = (FormContextRequired)handler;
		try
		{
			Long formId = Long.valueOf(request.getParameter(FormContextRequired.FORM_ID_NAME));
			controller.setFormId(formId);
			request.setAttribute(FormContextRequired.FORM_ID_NAME, formId);
		}
		catch (Exception e)
		{
			// either parameter is missing or invalid value
			throw new MissingServletRequestParameterException(FormContextRequired.FORM_ID_NAME, "Long");
		}
	}
	return true;
}
 
开发者ID:NCIP,项目名称:edct-formbuilder,代码行数:23,代码来源:FormContextInterceptor.java

示例11: handleMissingServletRequestParameter

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@Override
protected ResponseEntity<Object> handleMissingServletRequestParameter(final MissingServletRequestParameterException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) {
    logger.info(ex.getClass().getName());
    //
    final String error = ex.getParameterName() + " parameter is missing";
    final ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error);
    return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
}
 
开发者ID:junneyang,项目名称:xxproject,代码行数:9,代码来源:CustomRestExceptionHandler.java

示例12: handle400Error

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@ExceptionHandler(value = {IllegalArgumentException.class,
        BindException.class, // controller中参数绑定bean时异常,如数据类型不匹配等
        MissingServletRequestParameterException.class,
        MethodArgumentTypeMismatchException.class,
        HttpRequestMethodNotSupportedException.class})
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody
public Result handle400Error(HttpServletRequest req, Exception e) {
    String url = req.getMethod() + " " + req.getRequestURL() + "?" + req.getQueryString();
    logger.debug("不合法的url请求: {}", url);
    ResultEnum badRequest = ResultEnum.BAD_REQUEST;
    return ResultUtils.error(badRequest.getCode(), badRequest.getMessage(), url);
}
 
开发者ID:liufeng0103,项目名称:bnade-web-ssh,代码行数:14,代码来源:ExceptionHandle.java

示例13: handleMissingServletRequestParameterError

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@Loggable
@ResponseStatus(code = HttpStatus.CONFLICT)
@ExceptionHandler(MissingServletRequestParameterException.class)
public ErrorDto handleMissingServletRequestParameterError(MissingServletRequestParameterException ex) {
    return ErrorDto.builder()
            .errorCode(ErrorCodes.MISSING_REQUEST_PARAM)
            .errors(Collections.singleton(ex.getParameterName()))
            .message(ex.getLocalizedMessage())
            .build();
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:11,代码来源:ValidationErrorHandlers.java

示例14: handleMissingServletRequestParameter

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
@Override
protected ResponseEntity<Object> handleMissingServletRequestParameter(final MissingServletRequestParameterException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) {
	logger.info(ex.getClass().getName());
	//
	final String error = ex.getParameterName() + " parameter is missing";
	final AitException AitException = new AitException(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error);
	return handleExceptionInternal(ex, AitException, headers, AitException.getStatus(), request);
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:9,代码来源:AitRestExceptionHandler.java

示例15: handleMissingServletRequestParameterException

import org.springframework.web.bind.MissingServletRequestParameterException; //导入依赖的package包/类
/**
 * 400 - Bad Request
 */
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MissingServletRequestParameterException.class)
public Response handleMissingServletRequestParameterException(MissingServletRequestParameterException e) {
    log.error("缺少请求参数: {}", e);
    return new Response().failure("required_parameter_is_not_present");
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:10,代码来源:HttpExceptionAdvice.java


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