org.springframework.http.MediaType#APPLICATION_FORM_URLENCODED_VALUE源码实例Demo

下面列出了org.springframework.http.MediaType#APPLICATION_FORM_URLENCODED_VALUE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。


@PostMapping(value = "/{email}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "Create new person", responses = {
		@ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class), mediaType = MediaType.APPLICATION_JSON_VALUE), headers = @Header(name = "Location"), responseCode = "201"),
		@ApiResponse(responseCode = "409", description = "Person with such e-mail already exists") })
public ResponseEntity<String> addPerson(
		@Parameter(description = "E-Mail", required = true) @PathVariable("email") final String email,
		@Parameter(description = "First Name", required = true) @RequestParam("firstName") final String firstName,
		@Parameter(description = "Last Name", required = true) @RequestParam("lastName") final String lastName) {

	final PersonDTO person = people.get(email);

	if (person != null) {
		return ResponseEntity.status(HttpStatus.CONFLICT).body("Person with such e-mail already exists");
	}

	people.put(email, new PersonDTO(email, firstName, lastName));
	final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
			.buildAndExpand(UUID.randomUUID()).toUri();
	return ResponseEntity.created(location).build();
}
 

/**
 * 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);
    }
}
 

@RequestMapping(method = RequestMethod.POST,
		consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public Set<String> notifyByForm(@RequestHeader HttpHeaders headers,
		@RequestParam("path") List<String> request) {
	Map<String, Object> map = new HashMap<>();
	String key = "path";
	map.put(key, request);
	return notifyByPath(headers, map);
}
 
源代码4 项目: kid-bank   文件: SmsController.java

@PostMapping(
    path = "/sms",
    consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
    produces = MediaType.APPLICATION_XML_VALUE
)
public String incomingSms(TwilioIncomingRequest request) {
  PhoneNumber fromPhone = new PhoneNumber(request.getFrom());
  String commandText = request.getBody();

  UserProfile userProfile = userProfileRepository.findByPhoneNumber(fromPhone)
      .orElseThrow(() -> new NoSuchElementException(
          "Could not find authorized User Profile for " + fromPhone + ", command text was: " + commandText));

  return executeCommand(commandText, userProfile);
}
 
源代码5 项目: jfilter   文件: WSClassStrategyMultiple.java

@RequestMapping(value = MAPPING_SIGN_IN_STRATEGY_MULTIPLE,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signInn(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 

@PostMapping(value = "${graphql.jpa.path:/graphql}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ExecutionResult postForm( //
		@RequestParam final String query, //
		@RequestParam(required = false) final String variables) throws IOException {
	Map<String, Object> variablesMap = variablesStringToMap(variables);
	return graphQLExecutor.execute(query, variablesMap);
}
 
源代码7 项目: jfilter   文件: WSMethod.java

@FieldFilterSetting(fields = {"id", "email"}, behaviour = FilterBehaviour.KEEP_FIELDS)
@RequestMapping(value = MAPPING_SIGN_IN_KEEP_SINGLE_ANNOTATION,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signInKeepSingleAnnotation(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 
源代码8 项目: jfilter   文件: WSDynamicFilter.java

@DynamicFilter(DynamicSessionFilter.class)
@RequestMapping(value = MAPPING_DYNAMIC_REQUEST_ATTRIBUTE_FIELDS,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser sessionAttributeFields(HttpServletRequest request, @RequestParam("email") String email, @RequestParam("password") String password) {

    FilterUtil.useFilter(request, FilterFields.getFieldsBy(Arrays.asList("id", "password", "email")));
    return MockClassesHelper.getUserMock();
}
 
源代码9 项目: tutorials   文件: FeedbackForm.java

@PostMapping(
  path = "/feedback",
  consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public ResponseEntity<String> handleNonBrowserSubmissions(@RequestParam MultiValueMap paramMap) throws Exception {
    // Save feedback data
    return new ResponseEntity<String>("Thank you for submitting feedback", HttpStatus.OK);
}
 
源代码10 项目: jfilter   文件: WSMethod.java

@SessionStrategy(attributeName = "ROLE", attributeValue = "USER", ignoreFields = {
        @FieldFilterSetting(fields = {"id", "password"})
})
@RequestMapping(value = MAPPING_SIGN_IN_STRATEGY_ANNOTATION,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signInStrategyAnnotation(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 

@PostMapping(value = "/login", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ApiOperation("用户名密码登录,参数方式")
public ResponseMessage<Map<String, Object>> authorize(@RequestParam @ApiParam("用户名") String username,
                                                      @RequestParam @ApiParam("密码") String password,
                                                      @ApiParam(hidden = true) HttpServletRequest request) {

    return doLogin(username, password, WebUtil.getParameters(request));
}
 
源代码12 项目: jfilter   文件: WSMethod.java

@RequestMapping(value = MAPPING_SIGN_IN_DEFAULT,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signInDefault(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 
源代码13 项目: jfilter   文件: WSMethod.java

@DynamicFilter(DynamicSessionFilter.class)
@RequestMapping(value = MAPPING_SIGN_IN_DYNAMIC,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signInDynamic(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 
源代码14 项目: jfilter   文件: WSDynamicFilter.java

@DynamicFilter(MockDynamicNullFilter.class)
@RequestMapping(value = MAPPING_NULL_DYNAMIC_FILTER,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser nullFilter(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 
源代码15 项目: tutorials   文件: FeedbackForm.java

@PostMapping(
  path = "/web/feedback",
  consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public String handleBrowserSubmissions(Feedback feedback) throws Exception {
    // Save feedback data
    return "redirect:/feedback/success";
}
 
源代码16 项目: jfilter   文件: WSClassFile.java

@RequestMapping(value = MAPPING_SIGN_IN_FILE,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signIn(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 
源代码17 项目: jfilter   文件: WSClassFieldMultiple.java

@RequestMapping(value = MAPPING_SIGN_IN_FIELD_MULTIPLE,
        params = {"email", "password"}, method = RequestMethod.POST,
        consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
        produces = {MediaType.APPLICATION_JSON_VALUE})
public MockUser signInn(@RequestParam("email") String email, @RequestParam("password") String password) {
    return MockClassesHelper.getUserMock();
}
 

@RequestMapping(path = "/add", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@Override
public int add(@RequestAttribute("a") int a, @RequestAttribute("b") int b) {
  return super.add(a, b);
}
 

/**
 * POST a form parameter (and get a greeting back)
 */
@PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public SpecificMessage greetFromText(@RequestParam String addressee) {
    return new SpecificMessage(addressee, "Hello " + addressee);
}
 

@RequestMapping(value = "/callback", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
protected void postCallback(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
    handle(req, res);
}