Java Code Examples for org.springframework.http.MediaType#APPLICATION_FORM_URLENCODED_VALUE
The following examples show how to use
org.springframework.http.MediaType#APPLICATION_FORM_URLENCODED_VALUE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TicketsResource.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
/** * 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); } }
Example 2
Source File: PeopleRestService.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@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(); }
Example 3
Source File: AuthorizationController.java From hsweb-framework with Apache License 2.0 | 5 votes |
@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)); }
Example 4
Source File: WSClassFieldMultiple.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 5
Source File: WSClassFile.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 6
Source File: FeedbackForm.java From tutorials with MIT License | 5 votes |
@PostMapping( path = "/web/feedback", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) public String handleBrowserSubmissions(Feedback feedback) throws Exception { // Save feedback data return "redirect:/feedback/success"; }
Example 7
Source File: WSDynamicFilter.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 8
Source File: WSMethod.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 9
Source File: WSMethod.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 10
Source File: WSMethod.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 11
Source File: FeedbackForm.java From tutorials with MIT License | 5 votes |
@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); }
Example 12
Source File: WSDynamicFilter.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 13
Source File: WSMethod.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 14
Source File: GraphQLController.java From graphql-jpa-spring-boot-starter with MIT License | 5 votes |
@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); }
Example 15
Source File: WSClassStrategyMultiple.java From jfilter with Apache License 2.0 | 5 votes |
@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(); }
Example 16
Source File: SmsController.java From kid-bank with Apache License 2.0 | 5 votes |
@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); }
Example 17
Source File: PropertyPathEndpoint.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@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); }
Example 18
Source File: CodeFirstSpringmvc.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@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); }
Example 19
Source File: ContentTypeController.java From Spring-Boot-2-Fundamentals with MIT License | 4 votes |
/** * 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); }
Example 20
Source File: CallbackController.java From auth0-spring-security-mvc-sample with MIT License | 4 votes |
@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); }