本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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";
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
示例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()));
}
示例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");
}