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


Java MediaType.APPLICATION_FORM_URLENCODED_VALUE属性代码示例

本文整理汇总了Java中org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.APPLICATION_FORM_URLENCODED_VALUE属性的具体用法?Java MediaType.APPLICATION_FORM_URLENCODED_VALUE怎么用?Java MediaType.APPLICATION_FORM_URLENCODED_VALUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.http.MediaType的用法示例。


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

示例1: createTicketGrantingTicket

/**
 * Create new ticket granting ticket.
 *
 * @param requestBody username and password application/x-www-form-urlencoded values
 * @param request raw HttpServletRequest used to call this method
 * @return ResponseEntity representing RESTful response
 */
@RequestMapping(value = "/tickets", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public final ResponseEntity<String> createTicketGrantingTicket(@RequestBody final MultiValueMap<String, String> requestBody,
                                                               final HttpServletRequest request) {
    try (Formatter fmt = new Formatter()) {
        final TicketGrantingTicket tgtId = this.cas.createTicketGrantingTicket(obtainCredential(requestBody));
        final URI ticketReference = new URI(request.getRequestURL().toString() + '/' + tgtId.getId());
        final HttpHeaders headers = new HttpHeaders();
        headers.setLocation(ticketReference);
        headers.setContentType(MediaType.TEXT_HTML);
        fmt.format("<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\"><html><head><title>");
        //IETF//DTD HTML 2.0//EN\\\"><html><head><title>");
        fmt.format("%s %s", HttpStatus.CREATED, HttpStatus.CREATED.getReasonPhrase())
                .format("</title></head><body><h1>TGT Created</h1><form action=\"%s", ticketReference.toString())
                .format("\" method=\"POST\">Service:<input type=\"text\" name=\"service\" value=\"\">")
                .format("<br><input type=\"submit\" value=\"Submit\"></form></body></html>");
        return new ResponseEntity<String>(fmt.toString(), headers, HttpStatus.CREATED);
    } catch (final Throwable e) {
        LOGGER.error(e.getMessage(), e);
        return new ResponseEntity<String>(e.getMessage(), HttpStatus.BAD_REQUEST);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:TicketsResource.java

示例2: updateSlackToken

@RequestMapping(value = "/slack", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ApiOperation(value = "Update slack auth token")
public ResponseEntity<Map<String, Object>> updateSlackToken(@RequestParam(value = "token", required = true) @Valid String token) {
	ResponseEntity<Map<String, Object>> result = ResponseEntity.badRequest().build();
	try {
		if (StringUtils.isNotBlank(token)) {
			boolean slackResponse = slackService.isTokenValid(token);
			if (slackResponse) {
				configurationService.updateSlackToken(token);
				result = ResponseEntity.ok().build();
			}
		}
	} catch(Exception e) {
		logger.error("Exception while updating slack token.", e);
		result = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
	}
	return result;
}
 
开发者ID:Zymr,项目名称:visitormanagement,代码行数:18,代码来源:ConfigurationResource.java

示例3: updateEvent

/**
 * Method to save an event with RabbitMq
 * @return
 */
@RequestMapping(value = "/saveEvent", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String updateEvent(@RequestParam Map<String, String> body) {
	ObjectMapper mapper = new ObjectMapper();
	Event event = null;
	try {
		event = mapper.readValue(body.get("event"),Event.class);
	} catch (IOException e1) {
		Log
		.forContext("MemberName", "saveEvent")
		.forContext("Service", appName)
		.error(e1," IOException");
	}
	Log
	.forContext("MemberName", "saveEvent")
	.forContext("Service", appName)
	.forContext("event", body.get("event"))
	.information("Request : saveEvent");
	
	new RabbitClient(EXCHANGE).rabbitRPCRoutingKeyExchange(SerializationUtils.serialize(event),"saveEvent");
	return "{\"response\":\"success\"}";

}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:26,代码来源:WebEventController.java

示例4: saveParticipant

/**
* Method to add a participant to an event with RabbitMq
* @param id
* @return
*/
  @RequestMapping(value = "/saveParticipant",method = RequestMethod.POST,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
  public String saveParticipant(@RequestParam Map<String, String> body){
  	String person = body.get("person");
  	String event = body.get("event");
  	String res = null;
  	
  	String review ="{\"PersonId\":"+person+",\"EventId\":"+event+",\"Rate\": null,\"Text\": null}" ;
try {
	res =  new RabbitClient(EXCHANGE).rabbitRPCRoutingKeyExchange(review.getBytes(ENCODE),"addNewParticipant");
} catch (UnsupportedEncodingException e) {
	Log
	.forContext("MemberName", "saveParticipant")
	.forContext("Service", appName)
	.error(e,"UnsupportedEncodingException");
}
return res;
  }
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:22,代码来源:WebParticipantController.java

示例5: create

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = { MediaType.TEXT_HTML_VALUE,
                                                                                                                  MediaType.APPLICATION_XHTML_XML_VALUE })
public String create(@RequestParam("resId") String resId, RedirectAttributes attributes) {

    if (RESOURCE_ID_PATTERN.matcher(resId).matches()) {
        if (resourceIdRepository.findOneByValue(resId).isPresent()) {
            // error message
            addErrorMessage(attributes, "资源ID " + resId + " 已经存在。");
            attributes.addFlashAttribute("resId", resId);
        } else {
            resourceIdRepository.save(ResourceIdEntity.builder().value(resId).build());
            // success message
            addSuccessMessage(attributes, "已成功添加 " + resId + " 资源ID。");
        }
    } else {
        addErrorMessage(attributes, "资源ID " + resId + " 含有非法字符。(只能使用[a-zA-Z0-9_])");
        attributes.addFlashAttribute("resId", resId);
    }

    return "redirect:/resourceIds";
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:21,代码来源:ResourceIdAdminController.java

示例6: parseUrl

/**
 * Parse url scanned page.
 *
 * @param request the request
 * @return the scanned page
 */
@RequestMapping(value = "/parseurl", method = RequestMethod.POST,
        headers = "content-type=application/x-www-form-urlencoded",
        consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ScannedPage parseUrl(final HttpServletRequest request) {
    final ParameterMapParser parser = ParameterMapParser.parse(request.getParameterMap());
    final Mutable<ScannedPage> scannedPage = Mutable.of(null);

    QueryBlock.create()

            // Ensure the request has sent the required data
            .require(parser.has("url"), e -> e
                    .fail(HttpStatus.BAD_REQUEST, "Request does not have required data")
                    .done(data -> data.put("url", parser.get("url").toString())))

            // Return the processes medium
            .done(data -> scannedPage.mutate(pageParser.parseScannedPageFromUrl(data.get("url").toString())));

    scannedPage.ofNullable().ifPresent(newScannedPage ->
            scannedPage.mutate(scannedPageService
                    .findFirstByFacebookId(newScannedPage.getFacebookId())
                    .orElseGet(() -> scannedPageService.saveAndFlush(newScannedPage).orElse(newScannedPage)))
    );

    return scannedPage.get();
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:31,代码来源:ScannedPageController.java

示例7: create

@RequestMapping(path = "/_create", method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
    produces = {MediaType.TEXT_HTML_VALUE, MediaType.APPLICATION_XHTML_XML_VALUE})
public String create(@RequestParam(name = "routeId", required = true) String routeId,
    @RequestParam(name = "routePath", required = true) String routePath,
    @RequestParam(name = "routeUrl", required = true) String routeUrl,
    @RequestParam(name = "serviceId", required = true) String serviceId,
    @RequestParam(name = "stripPrefix", defaultValue = "false") Boolean stripPrefix,
    @RequestParam(name = "retryAble", defaultValue = "false") Boolean retryAble,
    @RequestParam(name = "sensitiveHeaders", defaultValue = "") String sensitiveHeaders,
    RedirectAttributes attributes) {
  if (zuulRouteRepository.findOneByRouteId(routeId).isPresent()) {
    addErrorMessage(attributes, routeId + "已经存在 ");
    resetRequestParams(routeId, routePath, routeUrl, serviceId, stripPrefix, retryAble,
        sensitiveHeaders, attributes);
    return "redirect:/restRoute.html?type=add";
  }
  ZuulRouteEntity entityRest = ZuulRouteEntity.builder()//
      .zuul_route_id(routeId)//
      .path(routePath)//
      .strip_prefix(stripPrefix)//
      .retryable(retryAble)//
      .url(routeUrl)//
      .service_id(serviceId)//
      .sensitiveHeaders(sensitiveHeaders)//
      .build();
  zuulRouteRepository.save(entityRest);
  publisher.publishEvent(new InstanceRegisteredEvent<>(this, this.environment));
  return "redirect:/restRoute.html";
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:30,代码来源:RestRouteAdminController.java

示例8: registerPerson

/**
 * Method to  add a person
 * @param pers
 * @param idTokenString
 * @return
 * @throws JsonMappingException 
 * @throws JsonParseException 
 * @throws GeneralSecurityException
 * @throws IOException
 */

@RequestMapping(value="/registerPerson", method = RequestMethod.POST,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String registerPerson(@RequestParam Map<String, String> body ){
	ObjectMapper mapper = new ObjectMapper();
	Log
	.forContext("person", body.get("person"))
	.forContext("userId",body.get("tokenid"))
	.forContext("Service", appName)
	.information("User Connection");		
	Person pers = null;
	try {
		pers = mapper.readValue((String) body.get("person"),Person.class);
	} catch (IOException e1) {
		Log
		.forContext("MemberName", "registerPerson")
		.forContext("Service", appName)
		.error(e1,"IOException");
	}
	if (pers != null) {
		Log
		.forContext("FirstName", pers.getFirstName())
		.forContext("LastName", pers.getLastName())
		.forContext("Job", pers.getJob())
		.information("Pers");
		
		return new RabbitClient(EXCHANGE).rabbitRPCRoutingKeyExchange(SerializationUtils.serialize(pers),"addPerson");
	} else {
		Log
		.forContext("Service", appName)
		.information("Invalid Token");
		return "{\"response\":\"error\"}";
	}		
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:43,代码来源:WebPersonController.java

示例9: dismissCourse

@PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String dismissCourse(Principal principal, Long dismissedId) {
    log.info("Post with [{}] as request body", dismissedId);
    Student student = getLoggedInStudent(principal);
    courseService.dismissCourse(student, dismissedId);
    return "redirect:/student/recommended";
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:7,代码来源:StudentRecommendedCoursesController.java

示例10: commitForm

@RequestMapping(value = "/{" + SUB_ID + "}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> commitForm(
        @RequestHeader(ErestHeaders.REQUEST_ID) String requestId,
        @RequestHeader(ErestHeaders.OPERATOR_ID) String operatorId,
        @PathVariable(OWNER_ID) String ownerId,
        @PathVariable(SUB_ID) String subId,
        @RequestParam MultiValueMap<String, String> map) {
    return commit(requestId, operatorId, ownerId, subId, map);
}
 
开发者ID:SINeWang,项目名称:kiimate,代码行数:9,代码来源:RefreshEntireValueCtl.java

示例11: commitForm

@RequestMapping(method = POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> commitForm(
        @RequestHeader(ErestHeaders.REQUEST_ID) String requestId,
        @RequestHeader(ErestHeaders.OPERATOR_ID) String operatorId,
        @PathVariable(OWNER_ID) String ownerId,
        @ModelAttribute SubscribeGlimpseApi.Form form) {
    return commit(requestId, ownerId, operatorId, form);
}
 
开发者ID:SINeWang,项目名称:kiimate,代码行数:8,代码来源:SubscribeGlimpseCtl.java

示例12: commitForm

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> commitForm(
        @RequestHeader(ErestHeaders.REQUEST_ID) String requestId,
        @RequestHeader(ErestHeaders.OPERATOR_ID) String operatorId,
        @PathVariable(OWNER_ID) String ownerId,
        @ModelAttribute DeclareInstanceApi.Form form) {
    return commit(requestId, operatorId, ownerId, form);
}
 
开发者ID:SINeWang,项目名称:kiimate,代码行数:8,代码来源:DeclareInstanceCtl.java

示例13: commitForm

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> commitForm(
        @RequestHeader(ErestHeaders.REQUEST_ID) String requestId,
        @RequestHeader(ErestHeaders.OPERATOR_ID) String operatorId,
        @PathVariable(OWNER_ID) String ownerId,
        @PathVariable(STATUS_ID) Long statusId,
        @ModelAttribute PublishStatusApi.Form form) {
    return commit(requestId, operatorId, ownerId, statusId, form);
}
 
开发者ID:SINeWang,项目名称:kiimate,代码行数:9,代码来源:PublishStatusCtl.java

示例14: commitForm

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> commitForm(
        @RequestHeader(ErestHeaders.REQUEST_ID) String requestId,
        @RequestHeader(ErestHeaders.OPERATOR_ID) String operatorId,
        @PathVariable(OWNER_ID) String ownerId,
        @PathVariable(STABILITY) String publication,
        @ModelAttribute PublishModelApi.Form form) {
    return commit(requestId, operatorId, ownerId, publication, form);
}
 
开发者ID:SINeWang,项目名称:kiimate,代码行数:9,代码来源:PublishModelCtl.java

示例15: update

/**
 * Update a base entity
 *
 * @param id      Id of the base entity
 * @param request the request
 * @return updated base entity
 */
@RequestMapping(value = "/{id}", method = RequestMethod.PUT,
        headers = "content-type=application/x-www-form-urlencoded",
        consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ResponseBody
public String update(@PathVariable final String id, final HttpServletRequest request) {
    final E initialEntity = getRepository().findOne(id);

    // todo change from toJson to Springs automatic encoding
    // the reason why it isnt at the moment is because of a lazy loading bug
    // even though the elements are not lazy loaded
    return processEntity(initialEntity, request).toJSON();
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:19,代码来源:BaseController.java


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