Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

GetMapping("/rest/v1/books") in spring rest api

@GetMapping("/rest/v1/books")public ResponseEntity<List<Book>> findAllBooks() {    List<Book> books = bookService.findAll();    return ResponseEntity.ok(books);  // return 200, with json body} @GetMapping("/rest/v1/books/{bookId}")public ResponseEntity<Book> findBookById(@PathVariable long bookId) {    try {        Book book = bookService.findById(bookId);        return ResponseEntity.ok(book);  // return 200, with json body    } catch (ResourceNotFoundException ex) {        return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); // return 404, with null body    }}
Comment

PREVIOUS NEXT
Code Example
Java :: refresh sharedpreferences going back java 
Java :: seek bar 
Java :: java abstract modifier 
Java :: update java windows 
Java :: Palindrome Program in Java. 
Java :: get runtime java 
Java :: initialize empty dictionary java 
Java :: what is a package in java 
Java :: java nested static class 
Java :: enhanced for loop arraylist 
Java :: java stream loop through list 
Java :: sending a excel in an attachment in email java 
Java :: java timeout exception 
Java :: User input (scanner) 
Java :: set web image to imageview android java 
Java :: remove duplicates from list java 
Java :: java finally block 
Java :: next line java does not take input 
Java :: java compile 
Java :: java tree traversal 
Java :: intent class for url and phone and others 
Java :: is it possible to declare two conditions in for loop in javascrip 
Java :: spring login response data 
Java :: java returns null 
Java :: spring security controlleradvice 
Java :: how to use another class in java inside of an action listenrer 
Java :: output of this 
Java :: natural log in java 
Java :: Execute method on load alternative 
Java :: Kadane Algorithm for maximum sub-array 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =