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


Java RequestParam類代碼示例

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


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

示例1: testService

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping(value = "testService", method = RequestMethod.POST)
public Object testService(@RequestParam(value = "ipPort", required = true) String ipPort,
    @RequestBody GrpcServiceTestModel model) throws Exception {
  String serviceUrl = "http://" + ipPort + "/service/test";
  HttpPost request = new HttpPost(serviceUrl);
  request.addHeader("content-type", "application/json");
  request.addHeader("Accept", "application/json");
  try {
    StringEntity entity = new StringEntity(gson.toJson(model), "utf-8");
    entity.setContentEncoding("UTF-8");
    entity.setContentType("application/json");
    request.setEntity(entity);
    HttpResponse httpResponse = httpClient.execute(request);
    if (httpResponse.getStatusLine().getStatusCode() == 200) {
      String minitorJson = EntityUtils.toString(httpResponse.getEntity());
      Object response = gson.fromJson(minitorJson, new TypeToken<Object>() {}.getType());
      return response;
    }
  } catch (Exception e) {
    throw e;
  }
  return null;
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:24,代碼來源:ServiceTestController.java

示例2: create

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
/**
 * Handle a POST method by creating a new Milkshake.
 *  Queries appropriate fruit service to check for inventory and consume the fruit into the milkshake
 *
 * @param flavor to create
 * @return a newly created Milkshake
 */
@RequestMapping(method = RequestMethod.POST)
public @ResponseBody Milkshake create(@RequestParam Flavor flavor) {

  try {
    FlavorProvider provider = getFlavorProvider(flavor);
    provider.getIngredients();
  } catch (IngredientException e) {
    throw new HttpClientErrorException(HttpStatus.TOO_MANY_REQUESTS, e.getMessage());
  }

  Milkshake milkshake = new Milkshake();
  milkshake.setId(counter.incrementAndGet());
  milkshake.setFlavor(flavor);
  return milkshake;
}
 
開發者ID:stelligent,項目名稱:mu-workshop-lab3,代碼行數:23,代碼來源:MilkshakeController.java

示例3: uploadFile

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@PostMapping("/api/upload")
public ResponseEntity<?> uploadFile(@RequestParam("file") MultipartFile multipartFile) {
    logger.debug("Single file upload!");

    if (multipartFile.isEmpty()) {
        return new ResponseEntity("Please select a file!", HttpStatus.OK);
    }

    try {
        String randomPath = saveUploadedFiles(Arrays.asList(multipartFile));
        return new ResponseEntity(serverAddress + "/leafer/" + randomPath, new HttpHeaders(), HttpStatus.OK);

    } catch (IOException e) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
}
 
開發者ID:ziwenxie,項目名稱:leafer,代碼行數:17,代碼來源:FileUploadController.java

示例4: login

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@GetMapping(value = "/login")
public ModelAndView login(
        @RequestParam(value = "error", required = false) String error,
        @RequestParam(value = "logout", required = false) String logout) {

    logger.info("******login(error): {} ***************************************", error);
    logger.info("******login(logout): {} ***************************************", logout);

    ModelAndView model = new ModelAndView();
    if (error != null) {
        model.addObject("error", "Invalid username and password!");
    }

    if (logout != null) {
        model.addObject("message", "You've been logged out successfully.");
    }
    model.setViewName("login");

    return model;

}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:22,代碼來源:LoginController.java

示例5: export

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping("report-query-export")
public void export(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String userId = currentUserHolder.getUserId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_userId", userId));
    page = reportQueryManager.pagedQuery(page, propertyFilters);

    List<ReportQuery> reportQuerys = (List<ReportQuery>) page.getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("report subject");
    tableModel.addHeaders("id", "name");
    tableModel.setData(reportQuerys);
    exportor.export(request, response, tableModel);
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:20,代碼來源:ReportQueryController.java

示例6: remove

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping("user-status-remove")
public String remove(@RequestParam("selectedItem") List<Long> selectedItem,
        RedirectAttributes redirectAttributes) {
    try {
        List<UserStatus> userStatuses = userStatusManager
                .findByIds(selectedItem);

        for (UserStatus userStatus : userStatuses) {
            userStatusChecker.check(userStatus);
        }

        userStatusManager.removeAll(userStatuses);
        messageHelper.addFlashMessage(redirectAttributes,
                "core.success.delete", "刪除成功");
    } catch (CheckUserStatusException ex) {
        logger.warn(ex.getMessage(), ex);
        messageHelper.addFlashMessage(redirectAttributes, ex.getMessage());
    }

    return "redirect:/auth/user-status-list.do";
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:22,代碼來源:UserStatusController.java

示例7: searchGames

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping(path = "/games")
public Games searchGames(@RequestParam(value = "console") String console,
                         @RequestParam(value = "name", required = false) String name,
                         @RequestParam(value = "genre", required = false) String genre,
                         @RequestParam(value = "developer", required = false) String developer,
                         @RequestParam(value = "publisher", required = false) String publisher,
                         @RequestParam(required = false, defaultValue = "0") int pageNumber,
                         @RequestParam(required = false, defaultValue = "0") int pageSize) {

    List<SearchCriterion> searchCriteria = new ArrayList<>();
    searchCriteria.add(new SearchCriterion("name", null, "like", name));
    //TODO if GENRES required, a list of search criterion can be created
    searchCriteria.add(new SearchCriterion("genres", null, "contains", genre));
    searchCriteria.add(new SearchCriterion("developer", null, "equal", developer));
    searchCriteria.add(new SearchCriterion("publisher", null, "equal", publisher));
    searchCriteria.add(new SearchCriterion("console", "shortName", "join", console));

    return service.searchGames(searchCriteria, pageNumber, pageSize);
}
 
開發者ID:MannanM,項目名稱:corporate-game-share,代碼行數:20,代碼來源:GameController.java

示例8: update

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping(value = "/activity/{id}", method = RequestMethod.PUT)
public Activity update(@PathVariable Long id, @RequestBody Activity input, @RequestParam("username") String username,
                       @RequestParam("password") String password) {
    validateAccountUserExists(username, password);
    final Activity activity = activityRepository.findOne(id);
    if (activity == null) {
        return null;
    } else {
        activity.setText(input.getText());
        activity.setTitle(input.getTitle());
        activity.setAuthor(input.getAuthor());
        activity.setTag1(input.getTag1());
        activity.setTag2(input.getTag2());
        activity.setTag3(input.getTag3());
        activity.setImgBase64(input.getImgBase64());
        return activityRepository.save(activity);
    }
}
 
開發者ID:sweIhm,項目名稱:sweiproject-tg2b-1,代碼行數:19,代碼來源:ActivityController.java

示例9: findByTo

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = { "toId", "toType", "relationType" })
@ResponseBody
public List<EntityRelation> findByTo(@RequestParam("toId") String strToId, @RequestParam("toType") String strToType,
    @RequestParam("relationType") String strRelationType,
    @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws IoTPException {
  checkParameter("toId", strToId);
  checkParameter("toType", strToType);
  checkParameter("relationType", strRelationType);
  EntityId entityId = EntityIdFactory.getByTypeAndId(strToType, strToId);
  checkEntityId(entityId);
  RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON);
  try {
    return checkNotNull(relationService.findByToAndType(entityId, strRelationType, typeGroup).get());
  } catch (Exception e) {
    throw handleException(e);
  }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:19,代碼來源:EntityRelationController.java

示例10: getDpmtRecordCis

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping(value="/dj/simple/deployments/{dpmtId}/cis", method = RequestMethod.GET)
@ResponseBody
public List<CmsDpmtRecord> getDpmtRecordCis(
		@PathVariable long dpmtId,
		@RequestParam(value="updatedAfter", required = false) Long updatedAfter,
		@RequestParam(value="state", required = false) String state,
		@RequestParam(value="execorder", required = false) Integer execOrder,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope){
	
	if (scope != null) {
		CmsDeployment dpmt = djManager.getDeployment(dpmtId);
		scopeVerifier.verifyScope(scope, dpmt);
	}

	if (updatedAfter != null) {
		return djManager.getDpmtRecordCis(dpmtId, new Date(updatedAfter));
	}
	else if (state == null && execOrder==null) {
		return djManager.getDpmtRecordCis(dpmtId);
	} else {
		return djManager.getDpmtRecordCis(dpmtId, state, execOrder);
	}
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:24,代碼來源:DpmtRestController.java

示例11: getHighestAlarmSeverity

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/alarm/highestSeverity/{entityType}/{entityId}", method = RequestMethod.GET)
@ResponseBody
public AlarmSeverity getHighestAlarmSeverity(
        @PathVariable("entityType") String strEntityType,
        @PathVariable("entityId") String strEntityId,
        @RequestParam(required = false) String searchStatus,
        @RequestParam(required = false) String status
) throws IoTPException {
    checkParameter("EntityId", strEntityId);
    checkParameter("EntityType", strEntityType);
    EntityId entityId = EntityIdFactory.getByTypeAndId(strEntityType, strEntityId);
    AlarmSearchStatus alarmSearchStatus = StringUtils.isEmpty(searchStatus) ? null : AlarmSearchStatus.valueOf(searchStatus);
    AlarmStatus alarmStatus = StringUtils.isEmpty(status) ? null : AlarmStatus.valueOf(status);
    if (alarmSearchStatus != null && alarmStatus != null) {
        throw new IoTPException("Invalid alarms search query: Both parameters 'searchStatus' " +
                "and 'status' can't be specified at the same time!", IoTPErrorCode.BAD_REQUEST_PARAMS);
    }
    checkEntityId(entityId);
    try {
        return alarmService.findHighestAlarmSeverity(entityId, alarmSearchStatus, alarmStatus);
    } catch (Exception e) {
        throw handleException(e);
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:26,代碼來源:AlarmController.java

示例12: export

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping("feedback-info-export")
public void export(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    page = feedbackInfoManager.pagedQuery(page, propertyFilters);

    List<FeedbackInfo> feedbackInfos = (List<FeedbackInfo>) page
            .getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("feedbackInfo");
    tableModel.addHeaders("id", "name");
    tableModel.setData(feedbackInfos);
    exportor.export(request, response, tableModel);
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:20,代碼來源:FeedbackInfoController.java

示例13: foodsGet

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@ApiOperation(value = "Gets all foods, optionally return stats per food", notes = "Return a list of all foods", response = FoodWithStats.class, responseContainer = "List", authorizations = {
    @Authorization(value = "Bearer")
}, tags={ "chef", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "A list of foods", response = FoodWithStats.class),
    @ApiResponse(code = 500, message = "An unexpected error occured.", response = FoodWithStats.class) })
@RequestMapping(value = "/foods",
    produces = { "application/json" }, 
    method = RequestMethod.GET)
@CrossOrigin          
 ResponseEntity<FoodsPage> foodsGet( @ApiParam(value = "") @RequestParam(value = "stats", required = false) Boolean stats,
     @ApiParam(value = "Request pagination page") @RequestParam(value = "page", required = false) String page,
     @ApiParam(value = "Request pagination size / num of foods") @RequestParam(value = "size", required = false) String size,
     @ApiParam(value = "Request foodType filter") @RequestParam(value = "foodType", required = false) String foodType,
     @ApiParam(value = "Request archived filter") @RequestParam(value = "archived", required = false) String archived,
     @ApiParam(value = "Request orderBy filter") @RequestParam(value = "orderBy", required = false) String orderBy,
     @ApiParam(value = "Request foods version") @RequestParam(value = "foods_version", required = false) @Valid @Digits( integer=9,  fraction=0 )Integer foods_version,
     @ApiParam(value = "Request orderBy filter") @RequestParam(value = "orderDirection", required = false) String orderDirection) throws ApiException, Exception;
 
開發者ID:jrtechnologies,項目名稱:yum,代碼行數:19,代碼來源:FoodsApi.java

示例14: deleteProject

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping(value = "/project/{projectId}", method = RequestMethod.DELETE)
@ResponseBody
@ApiOperation(
        value = "Deletes a project, specified by project ID",
        notes = "Deletes a project with all it's items and bookmarks",
        produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
        value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
        })
public Result<Boolean> deleteProject(@PathVariable final long projectId,
                                     @RequestParam(name = "force", required = false, defaultValue = "false")
                                             Boolean force) throws IOException {
    Project deletedProject = projectManager.deleteProject(projectId, force);
    return Result.success(true, MessageHelper.getMessage(MessagesConstants.INFO_PROJECT_DELETED, deletedProject
            .getId(), deletedProject.getName()));
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:17,代碼來源:ProjectController.java

示例15: preview

import org.springframework.web.bind.annotation.RequestParam; //導入依賴的package包/類
@RequestMapping(value = "/generator/preview", method = RequestMethod.POST)
public String preview(@RequestParam(value = "schema") String schema,
                      @RequestParam(value = "targetpackage") String targetpackage,
                      @RequestParam(value = "sourcetype", required = false) final String sourcetype,
                      @RequestParam(value = "annotationstyle", required = false) final String annotationstyle,
                      @RequestParam(value = "usedoublenumbers", required = false) final boolean usedoublenumbers,
                      @RequestParam(value = "includeaccessors", required = false) final boolean includeaccessors,
                      @RequestParam(value = "includeadditionalproperties", required = false) final boolean includeadditionalproperties,
                      @RequestParam(value = "propertyworddelimiters", required = false) final String propertyworddelimiters,
                      @RequestParam(value = "classname") String classname) throws IOException {

    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    JCodeModel codegenModel = getCodegenModel(schema, targetpackage, sourcetype, annotationstyle, usedoublenumbers, includeaccessors, includeadditionalproperties, propertyworddelimiters, classname);
    codegenModel.build(new CodeWriter() {
        @Override
        public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
            return byteArrayOutputStream;
        }

        @Override
        public void close() throws IOException {
            byteArrayOutputStream.close();
        }
    });
    return byteArrayOutputStream.toString("utf-8");
}
 
開發者ID:wu191287278,項目名稱:sc-generator,代碼行數:27,代碼來源:JsonSchemaController.java


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