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


Java RequestBody類代碼示例

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


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

示例1: testConnectorCallback

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@RequestMapping(value = "/CISCore/postmessage/other", method = RequestMethod.POST)
public ResponseEntity<Response> testConnectorCallback(@RequestBody CISOtherContent otherpayload) {
	log.info("--> testConnectorCallback");
	Response response = new Response();
	
	log.info(otherpayload);
	
	log.info("testConnectorCallback -->");
	return new ResponseEntity<Response>(response, HttpStatus.OK);
}
 
開發者ID:DRIVER-EU,項目名稱:CommonInformationSpace,代碼行數:11,代碼來源:CISCoreConnectorRestController.java

示例2: updateAllRecord

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
/**
	 * 更新當前全部記錄
	 * @throws InterruptedException 
	 * @throws IOException 
	 */
	@RequestMapping(value= "/updateAllRecord", method=RequestMethod.POST)
	public String updateAllRecord(@RequestBody List<Object> updateRecordList) throws IOException, InterruptedException {
		String executeFile = getExecuteFile();
		ArrayList<Thread> threadList = new ArrayList<Thread>();
		for(int i=0; i < updateRecordList.size(); i++) {
			HashMap<String, String> allRecord = (HashMap<String, String>) updateRecordList.get(i);
//			executePy(allRecord.get("jobTable"), allRecord.get("jobPath"), allRecord.get("jobName"), 
//					allRecord.get("jobDay"), allRecord.get("jobType"), executeFile);
			Thread newThread = new Thread(new MyRunable(allRecord, executeFile));
			newThread.start();
			threadList.add(newThread);

		}
		
		for(Thread thread: threadList) {
			thread.join();
		} 
		
		System.out.println("主線程執行完畢");
		return "index";
	}
 
開發者ID:lpj24,項目名稱:jobManage,代碼行數:27,代碼來源:JobManageController.java

示例3: sendEmail

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@ApiOperation(value = "Trimite email.", tags = {"email"})
@RequestMapping(value = {"/mail"}, method = {RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_VALUE,
        consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<String> sendEmail(@RequestBody @Valid EmailModel model) {
    logger.info("start: trimitere email");

    try {
        mailService.send(model);
    } catch (VaVedemApiException ex) {
        if (ex instanceof VaVedemEmailException) {
            logger.info(ex.getMessage());
            return new ResponseEntity("error send email", HttpStatus.BAD_REQUEST);
        }
    }

    return new ResponseEntity<String>(HttpStatus.OK);
}
 
開發者ID:CoruptiaUcide,項目名稱:va-vedem-api,代碼行數:19,代碼來源:MailAPI.java

示例4: updatePodInfo

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
/**
 * Create / update pod info.  This endpoint is protected by an "API key" to prevent unauthorized access which
 * could inject bogus pod information into the PodDirectory. For this implementation, the API key is just a
 * hardcoded constant.  Real implementations probably want something more secure - at least a different API key
 * for each pod. The API key is passed as an HTTP header value with name "X-API-KEY".
 *
 * @param podInfo PodInfo object containing metadata about a pod
 * @param apiKey API Key.  Comes from HTTP Header value "X-API-KEY"
 *
 * @return HTTP 401 - if API key missing or invalid<br/>
 *         HTTP 400 - if PodInfo bad or missing<br/>
 *         HTTP 200 - otherwise.
 */
@RequestMapping(method = RequestMethod.POST, path = "/podInfo")
public ResponseEntity updatePodInfo(@RequestBody PodInfo podInfo, @RequestHeader("X-API-KEY") String apiKey) {

    // Check API key
    if (StringUtils.isEmpty(apiKey) || !webhookConfiguration.getApiKey().equals(apiKey)) {
        return new ResponseEntity(HttpStatus.UNAUTHORIZED);
    }

    // Ensure pod info present and at least has company ID.
    if (StringUtils.isEmpty(podInfo.getCompanyId())) {
        return new ResponseEntity(HttpStatus.BAD_REQUEST);
    }

    // Store pod info
    podDirectory.addPodInfo(podInfo);

    return new ResponseEntity(HttpStatus.OK);

}
 
開發者ID:symphonyoss,項目名稱:app-auth-example,代碼行數:33,代碼來源:DirectoryWebhookController.java

示例5: updateOE_HEL_SP_AI_Stars

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@RequestMapping(value = "/updateOE_HEL_SP_AI_Stars")
@ResponseBody
public PageData updateOE_HEL_SP_AI_Stars(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("OE_TYPE"))) {
		return WebResult.requestFailed(10001, "參數缺失!", null);
	}
	else {
		if("1".equals(pd.getString("OE_TYPE"))){//專家
			appUserEvaluateMapper.updateHEL_STARS(pd);
		}else if("2".equals(pd.getString("OE_TYPE"))){//代理
			appUserEvaluateMapper.updateSP_STARS(pd);
		}else if("3".equals(pd.getString("OE_TYPE"))){//陪診
			appUserEvaluateMapper.updateAI_STARS(pd);
		}
		return WebResult.requestSuccess();
	}
}
 
開發者ID:noseparte,項目名稱:Spring-Boot-Server,代碼行數:18,代碼來源:AppUserEvaluateRestful.java

示例6: getDoctorInfo

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
/**
 * 醫生信息
 * @return
 */
@RequestMapping(value = "/get")
@ResponseBody
public PageData getDoctorInfo(@RequestBody PageData pd) throws Exception {
	if (StringUtils.isBlank(pd.getString("HEL_ID"))) {
		return WebResult.requestFailed(10001, "參數缺失!", null);
	}
	else {
		PageData earnestMoney = appServiceMapper.getEarestMoney();
		String searnestMoney = earnestMoney.getString("CODE");
		float f = Float.valueOf("500");
		if (StringUtils.isNotBlank(searnestMoney)) {
			f = Float.valueOf(searnestMoney);
		}
		PageData accInfo = appDoctorInfoMapper.getDoctorInfo(pd);
		accInfo.put("EARNEST_MONEY", f);
		List<PageData> videoList = appDoctorInfoMapper.getDoctorVideoList(pd);
		accInfo.put("videoList", videoList);
		List<PageData> deptVideoList = appDoctorInfoMapper.getDeptVideoList(accInfo);
		accInfo.put("deptVideoList", deptVideoList);
		return WebResult.requestSuccess(accInfo);
	}
}
 
開發者ID:noseparte,項目名稱:Spring-Boot-Server,代碼行數:27,代碼來源:AppDoctorInfoRestful.java

示例7: add

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@PostMapping("history")
public ResponseEntity<?> add(@RequestBody CalcEntry entry) {
	
	try
	{
		entry = CalcWorker.getResult( entry );
	}
	catch (CalcException e)
	{
		LOGGER.error("Exception while calculation result for {}", entry.getOperation());
		// TODO: Stacktrace in logger
		
		// TODO: Error Message (not only Error Status) to Frontend?
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
	}
	
	return ResponseEntity.ok(repo.save(entry));
}
 
開發者ID:ZaidoR1,項目名稱:calculator,代碼行數:19,代碼來源:CalcController.java

示例8: postHTML2

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@RequestMapping(
		value = "/changeInfo",
		method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE },
		consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ResponseEntity<ChangePasswordInfo> postHTML2(@RequestBody ChangePassword info){

	if (info.getEmail() == null || info.getPassword() == null || info.getNewPassword() == null
			|| info.getEmail().equals("") || info.getPassword().equals("") || info.getNewPassword().equals("")) {
		throw new HTTP404Exception("No se han introducido todos los datos");
	}
	
	Ciudadano ci = updateInfo.UpdateCitizen(info);
	
	if (ci == null) {
		throw new HTTP404Exception("Email o contraseña incorrectas");
	}
	
	
	return new ResponseEntity<ChangePasswordInfo>(new ChangePasswordInfo("Se ha cambiado correctamente la contraseña"),
			HttpStatus.OK);
}
 
開發者ID:Arquisoft,項目名稱:participants1b,代碼行數:22,代碼來源:UpdateInfoController.java

示例9: gerarTokenJwt

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
/**
 * Gera e retorna um novo token JWT.
 * 
 * @param authenticationDto
 * @param result
 * @return ResponseEntity<Response<TokenDto>>
 * @throws AuthenticationException
 */
@PostMapping
public ResponseEntity<Response<TokenDto>> gerarTokenJwt(
		@Valid @RequestBody JwtAuthenticationDto authenticationDto, BindingResult result)
		throws AuthenticationException {
	Response<TokenDto> response = new Response<TokenDto>();

	if (result.hasErrors()) {
		log.error("Erro validando lançamento: {}", result.getAllErrors());
		result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
		return ResponseEntity.badRequest().body(response);
	}

	log.info("Gerando token para o email {}.", authenticationDto.getEmail());
	Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(
			authenticationDto.getEmail(), authenticationDto.getSenha()));
	SecurityContextHolder.getContext().setAuthentication(authentication);

	UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationDto.getEmail());
	String token = jwtTokenUtil.obterToken(userDetails);
	response.setData(new TokenDto(token));

	return ResponseEntity.ok(response);
}
 
開發者ID:SergioColetto,項目名稱:borabeber-api,代碼行數:32,代碼來源:AuthenticationController.java

示例10: saveService

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
/**
 * Adds the service to the Service Registry.
 * @param request the request
 * @param response the response
 * @param result the result
 * @param service the edit bean
 */
@RequestMapping(method = RequestMethod.POST, value = {"saveService.html"})
public void saveService(final HttpServletRequest request,
                        final HttpServletResponse response,
                        @RequestBody final RegisteredServiceEditBean.ServiceData service,
                        final BindingResult result) {
    try {

        final RegisteredService svcToUse = registeredServiceFactory.createRegisteredService(service);
        final RegisteredService newSvc = this.servicesManager.save(svcToUse);
        logger.info("Saved changes to service {}", svcToUse.getId());

        final Map<String, Object> model = new HashMap<>();
        model.put("id", newSvc.getId());
        model.put("status", HttpServletResponse.SC_OK);
        JsonViewUtils.render(model, response);

    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:yuweijun,項目名稱:cas-server-4.2.1,代碼行數:28,代碼來源:RegisteredServiceSimpleFormController.java

示例11: track

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@ResponseBody
@RequestMapping(value = "/bed/track/histogram", method = RequestMethod.POST)
@ApiOperation(
        value = "Returns a histogram of BED records amount on regions of chromosome",
        notes = "It provides histogram for a BEd track with the given scale factor between the " +
                "beginning position with the first base having position 1 and ending position inclusive " +
                "in a target chromosome. All parameters are mandatory and described below:<br/><br/>" +
                "1) <b>id</b> specifies ID of a track;<br/>" +
                "2) <b>chromosomeId</b> specifies ID of a chromosome corresponded to a track;<br/>" +
                "3) <b>startIndex</b> is the most left base position for a requested window. The first base in a " +
                "chromosome always has got position 1;<br/>" +
                "4) <b>endIndex</b> is the last base position for a requested window. " +
                "It is treated inclusively;<br/>" +
                "5) <b>scaleFactor</b> specifies an inverse value to number of bases per one visible element" +
                " on a track (e.g., pixel) - IS IGNORED FOR NOW",
        produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
        value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
        })
public Result<Track<Wig>> loadHistogram(@RequestBody final TrackQuery trackQuery)
        throws HistogramReadingException {
    final Track<Wig> histogramTrack = convertToTrack(trackQuery);
    return Result.success(bedManager.loadHistogram(histogramTrack));
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:25,代碼來源:BedController.java

示例12: updateTask

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@PostMapping
@ApiOperation(value = "新增任務")
@RequiresPermissions("sys.task.scheduled.update")
public Object updateTask(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	Assert.notNull(scheduled.getJobType(), "JOBTYPE");
	Assert.notNull(scheduled.getTaskType(), "TASKTYPE");
	Assert.notNull(scheduled.getTargetObject(), "TARGETOBJECT");
	Assert.notNull(scheduled.getTargetMethod(), "TARGETMETHOD");
	Assert.notNull(scheduled.getTaskCron(), "TASKCRON");
	Assert.notNull(scheduled.getTaskDesc(), "TASKDESC");
	if (TaskType.dubbo.equals(scheduled.getTaskType())) {
		Assert.notNull(scheduled.getTargetSystem(), "TARGETSYSTEM");
	}
	scheduledService.updateTask(scheduled);
	return setSuccessModelMap(modelMap);
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:19,代碼來源:ScheduledController.java

示例13: executeAsyncScript

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
/**
 * Implements the "Execute Async Script" command See
 * https://www.w3.org/TR/webdriver/#dfn-execute-async-script
 */
@RequestMapping(value = "/session/{sessionId}/execute/async", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public @ResponseBody ResponseEntity<Response> executeAsyncScript(@PathVariable String sessionId,
		@RequestBody(required = false) String body) throws Throwable {
	LOGGER.info("executeAsyncScript -->");
	LOGGER.info("  -> " + body);
	LOGGER.info("  <- ERROR: unknown command");
	LOGGER.info("executeAsyncScript <--");

	return responseFactory.error(sessionId, ProtocolError.UNKNOWN_COMMAND);
}
 
開發者ID:MicroFocus,項目名稱:SilkAppDriver,代碼行數:15,代碼來源:W3CProtocolController.java

示例14: addWatcher

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
public void addWatcher(@RequestBody String provisionWatcher) {
  if (provisionWatcher != null) {
    if (update.addWatcher(provisionWatcher)) {
      logger.debug("New device watcher received to add devices with provision watcher id:"
          + provisionWatcher);
    } else {
      logger.error("Received add device provision watcher request without an id attached.");
      throw new NotFoundException("provisionWatcher", provisionWatcher);
    }
  }
}
 
開發者ID:edgexfoundry,項目名稱:device-mqtt,代碼行數:12,代碼來源:UpdateController.java

示例15: getPathTest

import org.springframework.web.bind.annotation.RequestBody; //導入依賴的package包/類
@RequestMapping(produces = "application/json")
public ResponseEntity<HttpJson> getPathTest(@RequestBody String test) {
    HttpJson inObj = new HttpJson(test);
    HttpJson json = new HttpJson();
    UserExtend ue = new UserExtend();
    json.setClassObject(ue);
    json.setClassName(String.class.toString());

    return new ResponseEntity<HttpJson>(json, HttpStatus.ACCEPTED);
}
 
開發者ID:okingjerryo,項目名稱:WeiMusicCommunity-server,代碼行數:11,代碼來源:PathController.java


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