BAEL-305: Some minor changes
This commit is contained in:
parent
9c5404ead8
commit
ed03a59711
|
@ -6,7 +6,7 @@ import com.baeldung.enterprise.patterns.front.controller.data.Bookshelf;
|
|||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BookCommand extends FrontCommand {
|
||||
public class SearchCommand extends FrontCommand {
|
||||
@Override
|
||||
public void process() throws ServletException, IOException {
|
||||
Book book = Bookshelf.getInstance()
|
|
@ -21,7 +21,7 @@ public class Bookshelf {
|
|||
|
||||
public Book findByTitle(String title) {
|
||||
return books.stream()
|
||||
.filter(book -> book.getTitle().equalsIgnoreCase(title))
|
||||
.filter(book -> book.getTitle().toLowerCase().contains(title.toLowerCase()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
<p>Our Bookshelf contains this title:</p>
|
||||
<h2>${book.getTitle()}</h2>
|
||||
<p>Author: ${book.getAuthor()}</p>
|
||||
<input type="submit" value="Buy it: ${book.getPrice()}$">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bookshelf: Title found</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Our Bookshelf contains this title:</p>
|
||||
<h2>${book.getTitle()}</h2>
|
||||
<p>Author: ${book.getAuthor()}</p>
|
||||
<input type="submit" value="Buy it: ${book.getPrice()}$">
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,2 +1,10 @@
|
|||
<p>Our Bookshelf doesn't contains this title:</p>
|
||||
<h2>${param.get("title")}</h2>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bookshelf: Title not found</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Our Bookshelf doesn't contains this title:</p>
|
||||
<h2>${param.get("title")}</h2>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1 +1,9 @@
|
|||
<p>Sorry, this command is not known!</p>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bookshelf: Command unknown</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Sorry, this command is not known!</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue