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


Java ServletRequestBindingException類代碼示例

本文整理匯總了Java中org.springframework.web.bind.ServletRequestBindingException的典型用法代碼示例。如果您正苦於以下問題:Java ServletRequestBindingException類的具體用法?Java ServletRequestBindingException怎麽用?Java ServletRequestBindingException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: handleMissingAndMalformedParametersValues

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的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

示例2: createVideoTranscodingSettings

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
private VideoTranscodingSettings createVideoTranscodingSettings(MediaFile file, HttpServletRequest request) throws ServletRequestBindingException {
    Integer existingWidth = file.getWidth();
    Integer existingHeight = file.getHeight();
    Integer maxBitRate = ServletRequestUtils.getIntParameter(request, "maxBitRate");
    int timeOffset = ServletRequestUtils.getIntParameter(request, "timeOffset", 0);
    int defaultDuration = file.getDurationSeconds() == null ? Integer.MAX_VALUE : file.getDurationSeconds() - timeOffset;
    int duration = ServletRequestUtils.getIntParameter(request, "duration", defaultDuration);
    boolean hls = ServletRequestUtils.getBooleanParameter(request, "hls", false);

    Dimension dim = getRequestedVideoSize(request.getParameter("size"));
    if (dim == null) {
        dim = getSuitableVideoSize(existingWidth, existingHeight, maxBitRate);
    }

    return new VideoTranscodingSettings(dim.width, dim.height, timeOffset, duration, hls);
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:17,代碼來源:StreamController.java

示例3: handle

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
@ExceptionHandler(ServletRequestBindingException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorResponse handle(final ServletRequestBindingException ex) {
    log.error("Missing parameter", ex);
    return new ErrorResponse("MISSING_PARAMETER", ex.getMessage());
}
 
開發者ID:nielsutrecht,項目名稱:spring-boot-aop,代碼行數:8,代碼來源:ExceptionHandlers.java

示例4: validateMapping

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
/**
 * Validate the given type-level mapping metadata against the current request,
 * checking HTTP request method and parameter conditions.
 * @param mapping the mapping metadata to validate
 * @param request current HTTP request
 * @throws Exception if validation failed
 */
protected void validateMapping(RequestMapping mapping, HttpServletRequest request) throws Exception {
	RequestMethod[] mappedMethods = mapping.method();
	if (!ServletAnnotationMappingUtils.checkRequestMethod(mappedMethods, request)) {
		String[] supportedMethods = new String[mappedMethods.length];
		for (int i = 0; i < mappedMethods.length; i++) {
			supportedMethods[i] = mappedMethods[i].name();
		}
		throw new HttpRequestMethodNotSupportedException(request.getMethod(), supportedMethods);
	}

	String[] mappedParams = mapping.params();
	if (!ServletAnnotationMappingUtils.checkParameters(mappedParams, request)) {
		throw new UnsatisfiedServletRequestParameterException(mappedParams, request.getParameterMap());
	}

	String[] mappedHeaders = mapping.headers();
	if (!ServletAnnotationMappingUtils.checkHeaders(mappedHeaders, request)) {
		throw new ServletRequestBindingException("Header conditions \"" +
				StringUtils.arrayToDelimitedString(mappedHeaders, ", ") +
				"\" not met for actual request");
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:30,代碼來源:DefaultAnnotationHandlerMapping.java

示例5: controllerAdvice

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
@Test
public void controllerAdvice() throws Exception {
	StaticWebApplicationContext cxt = new StaticWebApplicationContext();
	cxt.registerSingleton("exceptionHandler", ApplicationExceptionHandler.class);
	cxt.refresh();

	ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver();
	resolver.setApplicationContext(cxt);
	resolver.afterPropertiesSet();

	ServletRequestBindingException ex = new ServletRequestBindingException("message");
	resolver.resolveException(this.servletRequest, this.servletResponse, null, ex);

	assertEquals(400, this.servletResponse.getStatus());
	assertEquals("error content", this.servletResponse.getContentAsString());
	assertEquals("someHeaderValue", this.servletResponse.getHeader("someHeader"));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:ResponseEntityExceptionHandlerTests.java

示例6: BaseExceptionHandler

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的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: submit

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
@RequestMapping(value="/submit")
protected String submit(HttpServletRequest request,
		SessionStatus status
		) throws ServletRequestBindingException {
	UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
	PlayerData player = playerService.findPlayer(userSession.getGameId(), userSession.getMemberId());
	QuestionData q = (QuestionData) WebUtils.getSessionAttribute(request, "qsess");
	if (q == null) {
		logger.error("No session in preview post!");
		return "redirect:make";
	} 		
	logger.debug("================> qid="+q.getId());
	playerService.submitQuestion(player.getId(), q);
	// allow invitations to be sent now... question cannot be changed after this.
	gameService.beginGameInvitation(userSession.getGameId());
	request.getSession().removeAttribute("qsess");
	return "redirect:/game/create/invite/home";
}
 
開發者ID:kenfrank,項目名稱:trivolous,代碼行數:19,代碼來源:MasterCreate2Controller.java

示例8: onSubmit

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
@RequestMapping(value="/submit")
protected String onSubmit(HttpServletRequest request,
		  SessionStatus status
		) throws ServletRequestBindingException {
	UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
	PlayerData player = playerService.findPlayer(userSession.getGameId(), userSession.getMemberId());
	QuestionData q = (QuestionData) WebUtils.getSessionAttribute(request, "qsess");
	if (q == null) {
		logger.error("No session in preview post!");
		return "redirect:make";
	} 		
	logger.debug("================> qid="+q.getId());
	request.getSession().removeAttribute("qsess");
	playerService.submitQuestion(player.getId(), q);
	return "redirect:/game/game";
}
 
開發者ID:kenfrank,項目名稱:trivolous,代碼行數:17,代碼來源:GameQueueController.java

示例9: showForm

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
/**
 * Displays the form to add a DataImportTool(Migration Settings)
 * 
 * @param request
 * @param model
 * @return new ModelAndView
 * @throws ServletRequestBindingException
 */
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showForm(HttpServletRequest request, ModelMap model) throws ServletRequestBindingException{

	DataImportTool dit;
	Integer Id = ServletRequestUtils.getIntParameter(request, "id");
	
	if (Id != null) {
		dit = Context.getService(DataImportToolService.class).getDataImportTool();
	} else {
		dit = new DataImportTool();
	}
	
	model.addAttribute("dit", dit);
	return new ModelAndView("/module/dataimporttool/addMigrationSettings", model);
}
 
開發者ID:openmrs,項目名稱:openmrs-module-dataimporttool,代碼行數:24,代碼來源:DataImportToolStartMigrationController.java

示例10: handleException

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
private void handleException(Throwable x, HttpServletRequest request, HttpServletResponse response) throws IOException {
    if (x instanceof NestedServletException && x.getCause() != null) {
        x = x.getCause();
    }

    RESTController.ErrorCode code = (x instanceof ServletRequestBindingException) ? MISSING_PARAMETER : GENERIC;
    String msg = getErrorMessage(x);
    
    if (msg.contentEquals("EofException")) {
        LOG.warn("Error in REST API: broken Stream");
    }
    else
    {
        LOG.warn("Error in REST API: " + msg, x);
        RESTController.error(request, response, code, msg);
    }
    
}
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:19,代碼來源:RESTFilter.java

示例11: downloadAttachment

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
/**
 * Called by the download attachment action on a note. Method
 * gets the attachment input stream from the AttachmentService
 * and writes it to the request output stream.
 */
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=downloadAttachment")
public ModelAndView downloadAttachment(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
        HttpServletRequest request,
        HttpServletResponse response) throws ServletRequestBindingException, FileNotFoundException, IOException {
    // Get the attachment input stream
    String selectedLineIndex = uifForm.getActionParamaterValue("selectedLineIndex");
    Note note = ((DocumentFormBase) uifForm).getDocument().getNote(Integer.parseInt(selectedLineIndex));
    Attachment attachment = note.getAttachment();
    InputStream is = getAttachmentService().retrieveAttachmentContents(attachment);

    // Set the response headers
    response.setContentType(attachment.getAttachmentMimeTypeCode());
    response.setContentLength(attachment.getAttachmentFileSize().intValue());
    response.setHeader("Expires", "0");
    response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");
    response.setHeader("Content-Disposition",
            "attachment; filename=\"" + attachment.getAttachmentFileName() + "\"");

    // Copy the input stream to the response
    FileCopyUtils.copy(is, response.getOutputStream());
    return null;
}
 
開發者ID:aapotts,項目名稱:kuali_rice,代碼行數:29,代碼來源:DocumentControllerBase.java

示例12: handleUpdatePermissions

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
private ModelAndView handleUpdatePermissions(HttpServletRequest req, HttpServletResponse res, ArrayList<String> errorMessages, ArrayList<String> infoMessages) throws ServletRequestBindingException, BusinessException{
	logger.debug("handleUpdatePermissions - START");
	
	ModelAndView mav = new ModelAndView(MESSAGE_VIEW);
	try {
		RoleWeb rw = BLRole.getInstance().getRoleWeb(ServletRequestUtils.getIntParameter(req, ROLEID));
		int[] permsIds = ServletRequestUtils.getIntParameters(req, NEW_PERMISSIONS);
		rw.setPermissions(Tools.getInstance().getSetFromArray(permsIds));			
		
		BLRole.getInstance().updateRoleWeb(rw);
		
		infoMessages.add(messageSource.getMessage(UPDATE_MESSAGE, null, RequestContextUtils.getLocale(req)));
	} catch (BusinessException be) {
		logger.error("", be);
		errorMessages.add(messageSource.getMessage(UPDATE_ERROR, new Object[] {be.getCode(), ControllerUtils.getInstance().getFormattedCurrentTime()}, RequestContextUtils.getLocale(req)));
	} catch (Exception e){
		logger.error("", e);
		errorMessages.add(messageSource.getMessage(UPDATE_ERROR, new Object[] {null, ControllerUtils.getInstance().getFormattedCurrentTime()}, RequestContextUtils.getLocale(req)));
	}		
			
	logger.debug("handleUpdatePermissions - END");
	return mav;
}
 
開發者ID:CodeSphere,項目名稱:termitaria,代碼行數:24,代碼來源:RoleChangePermissionsController_OLD.java

示例13: handleGetPermissions

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
private ModelAndView handleGetPermissions(HttpServletRequest req, HttpServletResponse res, ArrayList<String> errorMessages, ArrayList<String> infoMessages) throws ServletRequestBindingException, BusinessException{
	logger.debug("handleGetPermissions - START");
	
	ModelAndView mav = new ModelAndView(getView());		
	try {
		int roleId = ServletRequestUtils.getIntParameter(req, ROLEID);		
		// get all permissions for the given role
		Set<Permission> permissions = BLRole.getInstance().getPermissions(roleId);
		// get all permissions, except those which contained in my role
		List<Permission> allPermissions = BLPermission.getInstance().getAllPermissionsNotInSet(permissions);
		
		mav.addObject(PERMISSIONS, permissions);
		mav.addObject(ALL_PERMISSIONS, allPermissions);
		mav.addObject(ROLEID, roleId);			
	} catch (BusinessException be) {
		logger.error("", be);
		errorMessages.add(messageSource.getMessage(GET_PERMISSIONS_ERROR, new Object[] {be.getCode(), ControllerUtils.getInstance().getFormattedCurrentTime()}, RequestContextUtils.getLocale(req)));
	} catch (Exception e){
		logger.error("", e);
		errorMessages.add(messageSource.getMessage(GET_PERMISSIONS_ERROR, new Object[] {null, ControllerUtils.getInstance().getFormattedCurrentTime()}, RequestContextUtils.getLocale(req)));
	}	
	
	logger.debug("handleGetPermissions - END");
	return mav;
}
 
開發者ID:CodeSphere,項目名稱:termitaria,代碼行數:26,代碼來源:RoleChangePermissionsController_OLD.java

示例14: handleGetPersons

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
/**
 * Get all persons from department
 * 
 * @author matti_joona
 * @throws ServletRequestBindingException 
 */
private ModelAndView handleGetPersons(HttpServletRequest request, ArrayList<String> infoMessages, ArrayList<String> errorMessages, Locale locale) throws BusinessException, ServletRequestBindingException{
	logger.debug("== LIST PERSONS FROM DEPARTMENT OPERATION ==");
	
	ModelAndView mav = new ModelAndView(VIEW_PERSONS_LIST);
	
	Integer departmentId = ServletRequestUtils.getRequiredIntParameter(request, DEPARTMENT_ID);
	Department dept = BLDepartment.getInstance().get(departmentId);		
	try {			
		Integer[] departmentIds = new Integer[1];
		departmentIds[0] = departmentId;
		List<Person> listPersons = BLPerson.getInstance().getFromDepartments(departmentIds);		
		getPersonJobsFromDept(listPersons, dept);	
		request.setAttribute(MODEL_DEPARTMENT_PERSONS, listPersons);
	} catch(BusinessException bexc){
		logger.error(bexc.getMessage(), bexc);
		errorMessages.add(messageSource.getMessage(PERSONSLISTFROMDEPARTMENT_ERROR, new Object[] {bexc.getCode(), ControllerUtils.getInstance().getFormattedCurrentTime()}, locale));
	}
		
	logger.debug("== END LIST PERSONS FROM DEPARTMENT OPERATION ==");
	mav.addObject(DEPARTMENT_ID, departmentId);
	return mav;
}
 
開發者ID:CodeSphere,項目名稱:termitaria,代碼行數:29,代碼來源:ChangeDepartmentPropertiesController.java

示例15: handleGetSubdepartments

import org.springframework.web.bind.ServletRequestBindingException; //導入依賴的package包/類
/**
 * Get all subdepartments from department
 * 
 * @author matti_joona
 * @throws ServletRequestBindingException 
 */
private ModelAndView handleGetSubdepartments(HttpServletRequest request, ArrayList<String> infoMessages, ArrayList<String> errorMessages, Locale locale) throws BusinessException, ServletRequestBindingException{
	logger.debug("== LIST SUBDEPARTMENTS FROM DEPARTMENT OPERATION ==");
	
	ModelAndView mav = new ModelAndView(VIEW_SUBDEPARTMENTS_LIST);		
	try {
		Integer departmentId = ServletRequestUtils.getRequiredIntParameter(request, DEPARTMENT_ID);
		List<Department> listDepts = BLDepartment.getInstance().listSubDepartments(departmentId);
		
		request.setAttribute(MODEL_DEPARTMENT_SUBDEPARTMENTS, listDepts);
	} catch(BusinessException bexc){
		logger.error(bexc.getMessage(), bexc);
		errorMessages.add(messageSource.getMessage(SUBDEPARTMETSLISTFROMDEPARTMENT_ERROR, new Object[] {bexc.getCode(), ControllerUtils.getInstance().getFormattedCurrentTime()}, locale));
	}

	logger.debug("== END LIST SUBDEPARTMENTS FROM DEPARTMENT OPERATION ==");
	return mav;
}
 
開發者ID:CodeSphere,項目名稱:termitaria,代碼行數:24,代碼來源:ChangeDepartmentPropertiesController.java


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