当前位置: 首页>>代码示例>>Java>>正文


Java GetMapping类代码示例

本文整理汇总了Java中org.springframework.web.bind.annotation.GetMapping的典型用法代码示例。如果您正苦于以下问题:Java GetMapping类的具体用法?Java GetMapping怎么用?Java GetMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GetMapping类属于org.springframework.web.bind.annotation包,在下文中一共展示了GetMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的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

示例2: serveFileOnline

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
/**
 * 在线显示文件
 * @param id
 * @return
 */
@GetMapping("/view/{id}")
@ResponseBody
public ResponseEntity<Object> serveFileOnline(@PathVariable String id) {

    File file = fileService.getFileById(id);

    if (file != null) {
        return ResponseEntity
                .ok()
                .header(HttpHeaders.CONTENT_DISPOSITION, "fileName=\"" + file.getName() + "\"")
                .header(HttpHeaders.CONTENT_TYPE, file.getContentType() )
                .header(HttpHeaders.CONTENT_LENGTH, file.getSize()+"")
                .header("Connection",  "close") 
                .body( file.getContent());
    } else {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("File was not fount");
    }

}
 
开发者ID:waylau,项目名称:mongodb-file-server,代码行数:25,代码来源:FileController.java

示例3: oneRawImage

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping(value = BASE_PATH + "/" + FILENAME + "/raw",
	produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public Mono<ResponseEntity<?>> oneRawImage(
	@PathVariable String filename) {
	// tag::try-catch[]
	return imageService.findOneImage(filename)
		.map(resource -> {
			try {
				return ResponseEntity.ok()
					.contentLength(resource.contentLength())
					.body(new InputStreamResource(
						resource.getInputStream()));
			} catch (IOException e) {
				return ResponseEntity.badRequest()
					.body("Couldn't find " + filename +
						" => " + e.getMessage());
			}
		});
	// end::try-catch[]
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:22,代码来源:HomeController.java

示例4: handleFederationRequest

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
/**
 * Handle federation request.
 *
 * @param response the response
 * @param request  the request
 * @throws Exception the exception
 */
@GetMapping(path = WSFederationConstants.ENDPOINT_FEDERATION_REQUEST)
protected void handleFederationRequest(final HttpServletResponse response, final HttpServletRequest request) throws Exception {
    final WSFederationRequest fedRequest = WSFederationRequest.of(request);
    switch (fedRequest.getWa().toLowerCase()) {
        case WSFederationConstants.WSIGNOUT10:
        case WSFederationConstants.WSIGNOUT_CLEANUP10:
            handleLogoutRequest(fedRequest, request, response);
            break;
        case WSFederationConstants.WSIGNIN10:
            handleInitialAuthenticationRequest(fedRequest, response, request);
            break;
        default:
            throw new UnauthorizedAuthenticationException("The authentication request is not recognized",
                    Collections.emptyMap());
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:24,代码来源:WSFederationValidateRequestController.java

示例5: verArticulo

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping("/articulo/{id}")
public String verArticulo (Model model, @PathVariable long id,HttpServletRequest request){
	
	Articulo articulo = articulo_repository.findOne(id);
	model.addAttribute("articulo", articulo);
	model.addAttribute("comentarios",comentario_repository.findByArticulo(articulo));
	model.addAttribute("admin",request.isUserInRole("ADMIN"));
	
	return "ver_articulo";
}
 
开发者ID:jeche21,项目名称:SaleWeb,代码行数:11,代码来源:SaleWebController.java

示例6: getSwitches

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
/**
 * Get all available links.
 *
 * @return list of links.
 */
@ApiOperation(value = "Get all available switches", response = SwitchDto.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"),
        @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"),
        @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"),
        @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"),
        @ApiResponse(code = 404, response = MessageError.class, message = "Not found"),
        @ApiResponse(code = 500, response = MessageError.class, message = "General error"),
        @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable")})
@GetMapping(path = "/switches")
@ResponseStatus(HttpStatus.OK)
public List<SwitchDto> getSwitches() {
    return switchService.getSwitches();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:20,代码来源:SwitchController.java

示例7: tweetSingle

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping(value = "/tweet/{year}/{month}/{day}/{title}")
public String tweetSingle(@PathVariable("year") Integer year,@PathVariable("month") Integer month,@PathVariable("day") Integer day,@PathVariable("title") String title, Model model) {
    model.addAttribute("tweet","selected");

    Article article = articleService.getArticleByTitle(title);
    model.addAttribute("article",article);

    List<String> tagsList = articleService.getArticleTagsByArticleId(article.getId());
    model.addAttribute("tagsList",tagsList.toString());

    return "front/theme/effe/tweetSingle";
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:13,代码来源:EffeController.java

示例8: getClassFile

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping(value = "get_class_file")
public void getClassFile(@RequestParam List<String> tableNames,
                         @RequestParam String url,
                         @RequestParam String userName,
                         @RequestParam String password,
                         @RequestParam(required = false) String pkgName,
                         HttpServletResponse response) throws SQLException, IOException {
    Connection conn = getConn(url, userName, password);
    Map<String, List<String>> nameWithJavaMap = getStringListMap(tableNames, conn, pkgName);
    conn.close();

    ServletOutputStream outputStream = response.getOutputStream();
    ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);


    for (Map.Entry<String, List<String>> stringListEntry : nameWithJavaMap.entrySet()) {
        zipOutputStream.putNextEntry(
                new ZipEntry(
                        getJavaClassName(stringListEntry.getKey()) + ".java"
                )
        );
        for (String line : stringListEntry.getValue()) {
            zipOutputStream.write(line.getBytes());
            zipOutputStream.write('\n');
        }
    }
    response.setContentType("application/zip;charset=utf-8");
    response.setHeader("Content-disposition", "attachment;filename= " + LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + ".zip");
    zipOutputStream.close();

}
 
开发者ID:chenjazz,项目名称:EntityGenerator,代码行数:32,代码来源:EntityGenApplication.java

示例9: editPage

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
/**
 * 编辑用户页
 *
 * @param id
 * @param model
 * @return
 */
@GetMapping("/editPage")
public String editPage(Model model, Long id) {
    UserVo userVo = userService.selectVoById(id);
    List<Role> rolesList = userVo.getRolesList();
    List<Long> ids = new ArrayList<Long>();
    for (Role role : rolesList) {
        ids.add(role.getId());
    }
    model.addAttribute("roleIds", ids);
    model.addAttribute("user", userVo);
    return "admin/user/userEdit";
}
 
开发者ID:TomChen001,项目名称:xmanager,代码行数:20,代码来源:UserController.java

示例10: defaultAfterLogin

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:8,代码来源:DefaultController.java

示例11: confirm

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
/**
 * Receive non-password protected message.
 */
@GetMapping("/confirm/{id:[a-f0-9]{64}}")
public String confirm(
        @PathVariable("id") final String id,
        @ModelAttribute("linkSecret") final String linkSecret,
        final Model model,
        final HttpSession session) {

    prepareMessage(id, linkSecret, null, model, session);

    return FORM_MSG_DISPLAY;
}
 
开发者ID:osiegmar,项目名称:setra,代码行数:15,代码来源:ReceiveController.java

示例12: showCodeCouple

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping("/")
ResponseEntity<String> showCodeCouple(){
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
    HttpEntity<?> entity = new HttpEntity<>(headers);
    return restTemplate.exchange(
            "http://producer-service/",
            HttpMethod.GET,
            entity,
            String.class);
}
 
开发者ID:kchrusciel,项目名称:Spring-Boot-Examples,代码行数:12,代码来源:ConsumerController.java

示例13: users

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping("/users")
public ResponseEntity<String> users() {
    ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {
    };

    return restTemplate.exchange(SERVICE, HttpMethod.GET, authenticationService.addAuthenticationHeader(), reference);
}
 
开发者ID:peavers,项目名称:swordfish-service,代码行数:8,代码来源:UserQueryGatewayRestController.java

示例14: validateToken

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
@GetMapping("/{token:.+}")
public ResponseEntity validateToken(@CookieValue("time") String time,
        @RequestHeader("Authorization") String[] authorization, @PathVariable String token,
        @RequestParam String url) {
    String temp = tokens.get(token);
    String auth = authorization[0];
    if (auth.equals("dummy")) {
        auth = authorization[1];
    }
    if (temp.equals(time) && auth.equals(token + time + url)) {
        return ResponseEntity.ok().build();
    } else {
        return ResponseEntity.badRequest().build();
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:16,代码来源:HeadersController.java

示例15: file

import org.springframework.web.bind.annotation.GetMapping; //导入依赖的package包/类
/**
 * Download attached file.
 */
@GetMapping("/file/{id:[a-f0-9]{64}}/{key:[a-f0-9]{64}}")
public ResponseEntity<StreamingResponseBody> file(@PathVariable("id") final String id,
                                                  @PathVariable("key") final String keyHex,
                                                  final HttpSession session) {

    final KeyIv keyIv =
        new KeyIv(BaseEncoding.base16().lowerCase().decode(keyHex), resolveFileIv(id, session));

    final DecryptedFile decryptedFile = messageService.resolveStoredFile(id, keyIv);

    final HttpHeaders headers = new HttpHeaders();

    // Set application/octet-stream instead of the original mime type to force download
    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);

    if (decryptedFile.getName() != null) {
        headers.setContentDispositionFormData("attachment", decryptedFile.getName(),
            StandardCharsets.UTF_8);
    }
    headers.setContentLength(decryptedFile.getOriginalFileSize());

    final StreamingResponseBody body = out -> {
        try (final InputStream in = messageService.getStoredFileInputStream(id, keyIv)) {
            ByteStreams.copy(in, out);
            out.flush();
        }

        messageService.burnFile(id);
    };

    return new ResponseEntity<>(body, headers, HttpStatus.OK);
}
 
开发者ID:osiegmar,项目名称:setra,代码行数:36,代码来源:ReceiveController.java


注:本文中的org.springframework.web.bind.annotation.GetMapping类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。