Java 类org.springframework.web.bind.annotation.RequestAttribute 实例源码

项目:incubator-servicecomb-saga    文件:FlightBookingController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "bookings", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> book(@RequestAttribute String customerId) {
  if (!customers.contains(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  return ResponseEntity.ok(String.format("{\n"
          + "  \"body\": \"Flight booked with id %s for customer %s\"\n"
          + "}",
      UUID.randomUUID().toString(),
      customerId));
}
项目:incubator-servicecomb-saga    文件:PaymentController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user"),
    @ApiResponse(code = 400, response = String.class, message = "insufficient account balance")
})
@RequestMapping(value = "payments", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> pay(@RequestAttribute String customerId) {
  if ("anonymous".equals(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  if (balance < 800) {
    throw new InvocationException(BAD_REQUEST, "Not enough balance in account of customer " + customerId);
  }

  balance -= 800;
  return ResponseEntity.ok(String.format("{\n"
          + "  \"body\": \"Payment made for customer %s and remaining balance is %d\"\n"
          + "}",
      customerId,
      balance));
}
项目:incubator-servicecomb-saga    文件:HotelReservationController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "reservations", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> reserve(@RequestAttribute String customerId) {
  if (!customers.contains(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  return ResponseEntity.ok(String.format("{\n"
          + "  \"body\": \"Hotel reserved with id %s for customer %s\"\n"
          + "}",
      UUID.randomUUID().toString(),
      customerId));
}
项目:spring-cloud-function    文件:MessageController.java   
@GetMapping("/**")
public ResponseEntity<Object> supplier(
        @RequestAttribute("org.springframework.web.servlet.HandlerMapping.pathWithinHandlerMapping") String path,
        @RequestHeader HttpHeaders headers,
        @RequestParam(required = false) boolean purge) {
    Route route = output(path);
    String channel = route.getChannel();
    if (bindings.getOutputs().contains(channel)) {
        Message<Collection<Object>> polled = poll(channel, route.getKey(), !purge);
        if (routes.contains(route.getKey()) || !polled.getPayload().isEmpty()
                || route.getKey() == null) {
            return convert(polled, headers);
        }
    }
    route = input(path);
    channel = route.getChannel();
    if (!bindings.getInputs().contains(channel)) {
        return ResponseEntity.notFound().build();
    }
    String body = route.getKey();
    body = body.contains("/") ? body.substring(body.lastIndexOf("/") + 1) : body;
    path = path.replaceAll("/" + body, "");
    return string(path, body, headers);
}
项目:burpextender-proxyhistory-webui    文件:ProxyHistoryController.java   
@GetMapping("/")
public String list(@RequestAttribute Connection dbconn, Model model) throws SQLException {
    String dbname = (String) servletContext.getAttribute("dbname");
    model.addAttribute("dbname", dbname);
    model.addAttribute("proxyHistories", ProxyHistory.getList(dbconn));
    return "index";
}
项目:burpextender-proxyhistory-webui    文件:ProxyHistoryController.java   
@GetMapping("/proxy-history/{logContext}/{messageRef}")
public String detail(@RequestAttribute Connection dbconn, Model model, @PathVariable String logContext,
        @PathVariable int messageRef) throws SQLException {
    model.addAttribute("logContext", logContext);
    model.addAttribute("messageRef", messageRef);
    ProxyHistory proxyHistory = ProxyHistory.getDetail(dbconn, logContext, messageRef);
    if (Objects.isNull(proxyHistory)) {
        servletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
        return "proxy-history-not-found";
    }
    model.addAttribute("proxyHistory", ProxyHistory.getDetail(dbconn, logContext, messageRef));
    model.addAttribute("charsetNames", AppContext.getAvailableCharsetNames());
    return "proxy-history";
}
项目:burpextender-proxyhistory-webui    文件:ProxyHistoryController.java   
@PostMapping("/proxy-history/{logContext}/{messageRef}")
public String updateCharset(@RequestAttribute Connection dbconn, Model model, @PathVariable String logContext,
        @PathVariable int messageRef, @RequestParam String requestCharset, @RequestParam String responseCharset)
        throws SQLException {
    ProxyHistory.updateCharset(dbconn, logContext, messageRef, requestCharset, responseCharset);
    // TODO affected row check
    return "redirect:/proxy-history/{logContext}/{messageRef}";
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvcSimplifiedMappingAnnotation.java   
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@PostMapping(path = "/responseEntity")
@Override
public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) {
  return super.responseEntity(c1, date);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/responseEntity", method = RequestMethod.POST)
@Override
public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) {
  return super.responseEntity(c1, date);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/responseEntity", method = RequestMethod.POST)
public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) {
  HttpHeaders headers = new HttpHeaders();
  headers.add("h1", "h1v " + c1.getContext().get(Const.SRC_MICROSERVICE).toString());

  InvocationContext c2 = ContextUtils.getInvocationContext();
  headers.add("h2", "h2v " + c2.getContext().get(Const.SRC_MICROSERVICE).toString());

  return new ResponseEntity<Date>(date, headers, HttpStatus.ACCEPTED);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/responseEntity", method = RequestMethod.PATCH)
public ResponseEntity<Date> responseEntityPATCH(InvocationContext c1, @RequestAttribute("date") Date date) {
  HttpHeaders headers = new HttpHeaders();
  headers.add("h1", "h1v " + c1.getContext().get(Const.SRC_MICROSERVICE).toString());

  InvocationContext c2 = ContextUtils.getInvocationContext();
  headers.add("h2", "h2v " + c2.getContext().get(Const.SRC_MICROSERVICE).toString());

  return new ResponseEntity<Date>(date, headers, HttpStatus.ACCEPTED);
}
项目:incubator-servicecomb-java-chassis    文件:SpringmvcSwaggerGeneratorContext.java   
@Override
protected void initParameterAnnotationMgr() {
  super.initParameterAnnotationMgr();

  parameterAnnotationMgr.register(CookieValue.class, new CookieValueAnnotationProcessor());
  parameterAnnotationMgr.register(PathVariable.class, new PathVariableAnnotationProcessor());
  parameterAnnotationMgr.register(RequestBody.class, new RequestBodyAnnotationProcessor());
  parameterAnnotationMgr.register(RequestHeader.class, new RequestHeaderAnnotationProcessor());
  parameterAnnotationMgr.register(RequestParam.class, new RequestParamAnnotationProcessor());
  parameterAnnotationMgr.register(RequestAttribute.class, new RequestAttributeAnnotationProcessor());
  parameterAnnotationMgr.register(RequestPart.class, new RequestPartAnnotationProcessor());
}
项目:incubator-servicecomb-java-chassis    文件:MethodMixupAnnotations.java   
@RequestMapping(
    path = "usingRequestMapping/{targetName}",
    method = {RequestMethod.POST},
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingRequestMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
项目:incubator-servicecomb-java-chassis    文件:MethodMixupAnnotations.java   
@GetMapping(
    path = "usingGetMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingGetMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
项目:incubator-servicecomb-java-chassis    文件:MethodMixupAnnotations.java   
@PutMapping(
    path = "usingPutMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingPutMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
项目:incubator-servicecomb-java-chassis    文件:MethodMixupAnnotations.java   
@PostMapping(
    path = "usingPostMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingPostMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
项目:incubator-servicecomb-java-chassis    文件:MethodMixupAnnotations.java   
@PatchMapping(
    path = "usingPatchMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingPatchMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
项目:incubator-servicecomb-java-chassis    文件:MethodMixupAnnotations.java   
@DeleteMapping(
    path = "usingDeleteMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingDeleteMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
项目:EventSoft    文件:ValoracionesController.java   
@RequestMapping(value = "/eliminar", method = RequestMethod.DELETE)
public String eliminar(@RequestAttribute("Valoracion") Valoracion valoracion) {
    FachadaIntegracion<Valoracion> fachadaIntegracion = FachadaIntegracion.newInstance(Valoracion.class);
    fachadaIntegracion.baja(valoracion.getId());

    return "valoracion-eliminada";
}
项目:incubator-servicecomb-saga    文件:GreetingController.java   
@RequestMapping(value = "/usableResource", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<String> postUsableResource(
    @RequestAttribute(name = "hello") String who,
    @RequestAttribute(name = "response") String response) {

  return ResponseEntity.ok("hello " + who + ", with response " + response);
}
项目:incubator-servicecomb-saga    文件:FlightBookingController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "bookings", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> cancel(@RequestAttribute String customerId) {
  if (!customers.contains(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  return ResponseEntity.ok(String.format("Flight booking cancelled with id %s for customer %s",
      UUID.randomUUID().toString(),
      customerId));
}
项目:incubator-servicecomb-saga    文件:PaymentController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "payments", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> refund(@RequestAttribute String customerId) {
  if ("anonymous".equals(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  balance += 800;
  return ResponseEntity.ok(String.format("Payment refunded for customer %s and remaining balance is %d",
      customerId,
      balance));
}
项目:incubator-servicecomb-saga    文件:HotelReservationController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "reservations", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> cancel(@RequestAttribute String customerId) {
  if (!customers.contains(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  return ResponseEntity.ok(String.format("Hotel reservation cancelled with id %s for customer %s",
      UUID.randomUUID().toString(),
      customerId));
}
项目:incubator-servicecomb-saga    文件:CarRentalController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "rentals", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> rent(@RequestAttribute String customerId) {
  log.info("Received car rental request from customer {}", customerId);
  if (!customers.contains(customerId)) {
    log.info("No such customer {}", customerId);
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  if ("snail".equals(customerId)) {
    try {
      log.info("Encountered extremely slow customer {}", customerId);
      int timeout = delay;
      delay = 0;
      TimeUnit.SECONDS.sleep(timeout);
      log.info("Finally served the extremely slow customer {}", customerId);
    } catch (InterruptedException e) {
      return new ResponseEntity<>("Interrupted", INTERNAL_SERVER_ERROR);
    }
  }

  return ResponseEntity.ok(String.format("{\n"
          + "  \"body\": \"Car rented with id %s for customer %s\"\n"
          + "}",
      UUID.randomUUID().toString(),
      customerId));
}
项目:incubator-servicecomb-saga    文件:CarRentalController.java   
@ApiResponses({
    @ApiResponse(code = 200, response = String.class, message = "authenticated user"),
    @ApiResponse(code = 403, response = String.class, message = "unauthenticated user")
})
@RequestMapping(value = "rentals", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE)
public ResponseEntity<String> cancel(@RequestAttribute String customerId) {
  if (!customers.contains(customerId)) {
    throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId);
  }

  return ResponseEntity.ok(String.format("Car rental cancelled with id %s for customer %s",
      UUID.randomUUID().toString(),
      customerId));
}
项目:simple-openid-provider    文件:LogoutPromptController.java   
@GetMapping
public String logoutPrompt(@RequestAttribute(name = "redirectUri", required = false) URI redirectUri,
        @RequestAttribute(name = "state", required = false) State state, Model model) {
    model.addAttribute("redirectUri", redirectUri);
    model.addAttribute("state", state);

    return "logout";
}
项目:spring-cloud-sample    文件:AccountController.java   
@RequestMapping("/logout")
@Authorize
public String logout(@RequestAttribute(USER_CONTEXT_KEY) UserContext userContext, HttpServletResponse response) throws UserApiException {
    LogoutReq logoutReq = new LogoutReq();
    logoutReq.setAccessToken(userContext.getAccessToken());
    accountApi.logout(logoutReq);
    userContextProcessor.destroy(userContext, response);
    return "redirect:/";
}
项目:spring-cloud-function    文件:FunctionController.java   
@GetMapping(path = "/**")
@ResponseBody
public Object get(
        @RequestAttribute(required = false, name = "org.springframework.cloud.function.web.flux.constants.WebRequestConstants.function") Function<Flux<?>, Flux<?>> function,
        @RequestAttribute(required = false, name = "org.springframework.cloud.function.web.flux.constants.WebRequestConstants.supplier") Supplier<Flux<?>> supplier,
        @RequestAttribute(required = false, name = "org.springframework.cloud.function.web.flux.constants.WebRequestConstants.argument") String argument) {
    if (function != null) {
        return value(function, argument);
    }
    return supplier(supplier);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvcSimplifiedMappingAnnotation.java   
@PostMapping(path = "/uploadWithoutAnnotation", produces = MediaType.TEXT_PLAIN_VALUE)
public String fileUploadWithoutAnnotation(MultipartFile file1, MultipartFile file2,
    @RequestAttribute("name") String name) {
  return super.fileUpload(file1, file2, name);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvcSimplifiedMappingAnnotation.java   
@PostMapping(path = "/addDate")
@Override
public Date addDate(@RequestAttribute("date") Date date, @QueryParam("seconds") long seconds) {
  return super.addDate(date, seconds);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvcSimplifiedMappingAnnotation.java   
@PostMapping(path = "/add")
@Override
public int add(@RequestAttribute("a") int a, @RequestAttribute("b") int b) {
  return super.add(a, b);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@RequestMapping(path = "/uploadWithoutAnnotation", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE)
public String fileUploadWithoutAnnotation(MultipartFile file1, MultipartFile file2,
    @RequestAttribute("name") String name) {
  return super.fileUpload(file1, file2, name);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@RequestMapping(path = "/addDate", method = RequestMethod.POST)
@Override
public Date addDate(@RequestAttribute("date") Date date, @QueryParam("seconds") long seconds) {
  return super.addDate(date, seconds);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@RequestMapping(path = "/add", method = RequestMethod.POST)
@Override
public int add(@RequestAttribute("a") int a, @RequestAttribute("b") int b) {
  return super.add(a, b);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@RequestMapping(path = "/addDate", method = RequestMethod.POST)
public Date addDate(@RequestAttribute("date") Date date, @QueryParam("seconds") long seconds) {
  return new Date(date.getTime() + seconds * 1000);
}
项目:incubator-servicecomb-java-chassis    文件:CodeFirstSpringmvc.java   
@RequestMapping(path = "/add", method = RequestMethod.POST)
public int add(@RequestAttribute("a") int a, @RequestAttribute("b") int b) {
  return a + b;
}
项目:incubator-servicecomb-java-chassis    文件:RequestAttributeAnnotationProcessor.java   
@Override
protected String getAnnotationParameterName(Object annotation) {
  return ((RequestAttribute) annotation).name();
}
项目:incubator-servicecomb-saga    文件:DummyController.java   
@RequestMapping(value = "/faultyResource", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<String> postFaultyResource(@RequestParam(name = "foo") String foo, @RequestAttribute(name = "hello") String hello) {
  throw new RuntimeException("no such resource");
}