Example usage for org.springframework.web.servlet.mvc.method.annotation MvcUriComponentsBuilder fromMethodCall

List of usage examples for org.springframework.web.servlet.mvc.method.annotation MvcUriComponentsBuilder fromMethodCall

Introduction

In this page you can find the example usage for org.springframework.web.servlet.mvc.method.annotation MvcUriComponentsBuilder fromMethodCall.

Prototype

public static UriComponentsBuilder fromMethodCall(Object info) 

Source Link

Document

Create a UriComponentsBuilder by invoking a "mock" controller method.

Usage

From source file:su90.mybatisdemo.utils.UriUtils.java

public static URI generateUri(Object info) {
    UriComponents uriComponents = MvcUriComponentsBuilder.fromMethodCall(info).build();
    return uriComponents.encode().toUri();
}

From source file:su90.mybatisdemo.utils.UriUtils.java

public static String generateAsciiStr(Object info) {
    UriComponents uriComponents = MvcUriComponentsBuilder.fromMethodCall(info).build();
    return uriComponents.encode().toUri().toASCIIString();
}

From source file:su90.mybatisdemo.utils.UriUtils.java

public static Href generateHref(Object info) {
    UriComponents uriComponents = MvcUriComponentsBuilder.fromMethodCall(info).build();
    return new Href(uriComponents.encode().toUri().toASCIIString());
}

From source file:com.training.rest.api.BookController.java

@RequestMapping(value = "/books", method = RequestMethod.POST)
public ResponseEntity<Void> addBook(@RequestBody Book book) {
    Book saved = bookService.save(book);
    URI location = MvcUriComponentsBuilder.fromMethodCall(on(BookController.class).getBook(saved.getId()))
            .build().toUri();/* www  . ja  v  a  2 s .  c om*/

    return ResponseEntity.created(location).build();
}