本文整理汇总了Java中org.springframework.web.bind.annotation.RequestMethod.POST属性的典型用法代码示例。如果您正苦于以下问题:Java RequestMethod.POST属性的具体用法?Java RequestMethod.POST怎么用?Java RequestMethod.POST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.web.bind.annotation.RequestMethod
的用法示例。
在下文中一共展示了RequestMethod.POST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
@RequestMapping(value = "/login",method = RequestMethod.POST)
public @ResponseBody
LoginResponse login(@RequestBody LoginBody loginBody, HttpServletRequest request, HttpServletResponse response){
// Authentication arequest = tokenServices.autoLogin(request,response);
// Authentication result = am.authenticate(arequest);
// SecurityContextHolder.getContext().setAuthentication(result);
// return new LoginResponse("success",arequest.getCredentials().toString());
try {
Authentication arequest = new UsernamePasswordAuthenticationToken(loginBody.getUsername(),loginBody.getPassword());
Authentication result = am.authenticate(arequest);
SecurityContextHolder.getContext().setAuthentication(result);
return new LoginResponse("success",arequest.getCredentials().toString());
} catch(AuthenticationException e) {
System.out.println("Authentication failed: " + e.getMessage());
}
return new LoginResponse("fail");
}
示例2: loginDo
@RequestMapping(value="login", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
if (!PermissionInterceptor.ifLogin(request)) {
if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)
&& PropertiesUtil.getString("xxl.job.login.username").equals(userName)
&& PropertiesUtil.getString("xxl.job.login.password").equals(password)) {
boolean ifRem = false;
if (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember)) {
ifRem = true;
}
PermissionInterceptor.login(response, ifRem);
} else {
return new ReturnT<String>(500, "账号或密码错误");
}
}
return ReturnT.SUCCESS;
}
示例3: createConsumer
@Transactional
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@RequestMapping(value = "/consumers", method = RequestMethod.POST)
public ConsumerToken createConsumer(@RequestBody Consumer consumer,
@RequestParam(value = "expires", required = false)
@DateTimeFormat(pattern = "yyyyMMddHHmmss") Date
expires) {
if (StringUtils.isContainEmpty(consumer.getAppId(), consumer.getName(),
consumer.getOwnerName(), consumer.getOrgId())) {
throw new BadRequestException("Params(appId、name、ownerName、orgId) can not be empty.");
}
Consumer createdConsumer = consumerService.createConsumer(consumer);
if (expires == null) {
expires = DEFAULT_EXPIRES;
}
return consumerService.generateAndSaveConsumerToken(createdConsumer, expires);
}
示例4: getChildList
/**
*
* @param body JSon в виде: {"filePath":"path"}
* @return FileOperationModel/ Код ошибки, описание и содержимое каталога: директории и файлы в виде перечисления
*/
@RequestMapping(value = "file/getChills", method = RequestMethod.POST
,produces = "application/json"
,consumes = MediaType.APPLICATION_JSON_VALUE
)
public FileOperationModel getChildList(@RequestBody String body){
FileOperationModel model = new FileOperationModel();
FileOperation fo = new FileOperation();
JSONObject jsonObject = new JSONObject(body);
String filePath = jsonObject.getString("filePath");
ArrayList<String> chills = fo.setFilePath(filePath).getChills();
model.setErrorCode(0);
model.setCodeDescription("Успех");
model.setFileContent(chills.toString());
return model;
}
示例5: startProcess
@RequestMapping(value = "api/processes/startProcess", method = RequestMethod.POST)
public @ResponseBody Callable<ResponseEntity<ProcessStartedDTO>> startProcess(
@RequestBody final ProcessStartDTO processStartDTO, final HttpServletRequest request) {
return () -> {
final HttpHeaderUser user = new HttpHeaderUser(request);
return processEngineCaller.startProcess(processStartDTO, user).get();
};
}
示例6: signup
@RequestMapping(value="/signup/new", method=RequestMethod.POST)
public String signup(final @Valid SignupForm signupForm,
final BindingResult result,
RedirectAttributes redirectAttributes) {
if(result.hasErrors()) {
return "signup/form";
}
String email = signupForm.getEmail();
if(calendarService.findUserByEmail(email) != null) {
result.rejectValue("email", "errors.signup.email", "Email address is already in use. FOO");
redirectAttributes.addFlashAttribute("error", "Email address is already in use. FOO");
return "signup/form";
}
CalendarUser user = new CalendarUser();
user.setEmail(email);
user.setFirstName(signupForm.getFirstName());
user.setLastName(signupForm.getLastName());
user.setPassword(signupForm.getPassword());
int id = calendarService.createUser(user);
user.setId(id);
userContext.setCurrentUser(user);
redirectAttributes.addFlashAttribute("message", "You have successfully signed up and logged in.");
return "redirect:/";
}
示例7: instanceRestart
@ApiOperation(value = "Restart an instance selected by its ID", notes = "", response = Void.class, tags={ "Instance", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/connections/{connection}/instance/{id}/restart",
produces = { "application/json" },
method = RequestMethod.POST)
ResponseEntity<Void> instanceRestart(@ApiParam(value = "name of selected container", required = true) @PathVariable("id") String id, @ApiParam(value = "", required = true) @PathVariable("connection") String connection);
示例8: scanCode
@RequestMapping(value = "/scanCode", method = RequestMethod.POST)
public ResponseEntity<ScanResult> scanCode(@RequestBody Map<String, Object> map) {
if (!map.containsKey("apiKey") || !map.containsKey("image")) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
String base64 = (String)map.get("image");
String userApiKey = (String)map.get("apiKey");
if (API_KEY.equals(userApiKey)) {
// Authorised access
try {
Image myImage = new Image(base64);
CornerAnalyzer analyzer = new CornerAnalyzer(new PictureUtils(myImage.getImage()));
analyzer.scanCorners();
Code code = new Code(myImage, new ArrayList<Point<Double>>() {{
add(new Point<>((double) analyzer.getTopLeft().getY(),
(double)analyzer.getTopLeft().getX()));
add(new Point<>((double) analyzer.getTopRight().getY(),
(double)analyzer.getTopRight().getX()));
add(new Point<>((double) analyzer.getBottomLeft().getY(),
(double)analyzer.getBottomLeft().getX()));
add(new Point<>((double) analyzer.getBottomRight().getY(),
(double)analyzer.getBottomRight().getX()));
}});
return new ResponseEntity<>(
new ScanResult(storage.getData(code.getCode())),
HttpStatus.OK);
} catch (IOException e) {
Logger.getGlobal().log(Level.SEVERE, String.valueOf(e));
}
}
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
示例9: deleteFromButton
@RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
public RedirectView deleteFromButton(@PathVariable Long id, Model model, RedirectAttributes red) {
Category category = categoriesService.findOne(id);
if (category == null)
red.addFlashAttribute("msg", "not found");
else {
categoriesService.delete(category);
red.addFlashAttribute("msg", "Succes");
}
Iterable<Category> categories = categoriesService.findAll();
model.addAttribute("categories", categories);
return new RedirectView(ApplicationProperties.PROJECT_NAME + "administratorSite/categories/delete");
}
示例10: save
@RequestMapping(value = "/agents", method = RequestMethod.POST)
@ResponseBody
public Agent save(@RequestBody Agent agent) throws Exception {
try {
return repository.save(agent);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
示例11: modifica
@RequestMapping(value = "/update", method = { RequestMethod.POST })
public String modifica(@ModelAttribute User user) {
if (isPasswordChanged(user)) {
user.setPassword(DigestUtils.md5Hex(user.getPassword()));
}
userService.update(user);
// authenticate the user and redirect on the welcome page
new AuthenticationHolder().updateUser(user);
return "redirect:/dashboard";
}
示例12: runScript
@RequestMapping(value = "/{moduleName}/run-script", method = RequestMethod.POST,
consumes = "multipart/form-data")
public ResponseEntity<?> runScript(@PathVariable String moduleName, @RequestPart("file") MultipartFile file)
throws ServiceException, CheckException {
String result = moduleService.runScript(moduleName, file);
return ResponseEntity.ok(result);
}
示例13: importProcess
@RequestMapping(value = "api/import", method = RequestMethod.POST)
public @ResponseBody Callable<ResponseEntity<Boolean>> importProcess(
final @RequestBody ImportProcessModelDTO processModelDTO, final HttpServletRequest request) {
return () -> {
final HttpHeaderUser user = new HttpHeaderUser(request);
return owlImportGatewayCaller.importProcessModel(processModelDTO, user).get();
};
}
示例14: searchGenesInProject
@ResponseBody
@RequestMapping(value = "/project/{projectId}/filter/vcf/searchGenes", method = RequestMethod.POST)
@ApiOperation(
value = "Searches for IDs of genes, that are affected by variations",
notes = "Searches for IDs of genes, that are affected by variations located in VCF files, specified by " +
"ids, in a given project, specified by project ID",
produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
})
public Result<Set<String>> searchGenesInProject(@PathVariable(value = PROJECT_ID_PARAM) long projectId,
@RequestBody GeneSearchQuery geneQuery) throws IOException {
return Result.success(featureIndexManager.searchGenesInVcfFilesInProject(projectId, geneQuery.getSearch(),
geneQuery.getVcfIds()));
}
示例15: loginout
@RequestMapping(value = "logout", method = { RequestMethod.GET,
RequestMethod.POST })
public String loginout(HttpSession session)
{
return "redirect:"+ShiroCasConfiguration.logoutUrl;
}