-1
コンソールからブラウザへの出力を正しく取得する方法https://localhost:8080/。私は他の小さなspring mvcの快適なWebサービスプロジェクトに取り組んでいました。私はlocalhost:8080の日付をスムーズにすることができました。コンソールからの出力をlocalhostに取得する:8080
ここでは、出力の一部されています
Customer: Customer [userId=1, forename=homer, lastname=simpson, [email protected], mobileNumber=0781 123 456, password=marge, orders=[
Order [orderId=0 total Order cost: 86.9, orderItems=[
OrderItem [item=Item [title=Dummies Guide to Dummies, publisher=Red Penguin, price=10.45, yearPublished=2014] Book [author=Man Equine], count=2 total cost=20.9],
OrderItem [item=Item [title=Release the hounds, publisher=Red Penguin, price=22.0, yearPublished=2014] Book [author=Rufus Ruff], count=3 total cost=66.0]]],
どちらか
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Mar 22 23:20:49 EET 2017
There was an unexpected error (type=Not Found, status=404).
No message available
それとも
Firefox can't establish a connection to the server at localhost:8080.
ここではBackendServiceImplクラスである:
public class BackendServiceImpl implements BackendService {
private static final String[] bookTitles = new String[]{"Dummies Guide to Dummies","Release the hounds","How to be happy"};
private static final float[] bookPrice = new float[]{10.45f, 22.00f, 5.50f};
private static final String[] bookAuthors = new String[]{"Man Equine","Rufus Ruff","Oona Appy"};
private static final Random random = new Random();
private static final List<Book> bookList = new ArrayList<Book>();
static {
for (int index = 0; index < bookTitles.length; index++) {
bookList.add(createBook(index));
}
}
private Map<Integer, Customer> customers = new ConcurrentHashMap<Integer, Customer>();
private Map<Integer, Order> orders = new ConcurrentHashMap<Integer, Order>();
private AtomicInteger customerIdCounter = new AtomicInteger();
private AtomicInteger orderIdCounter = new AtomicInteger();
public BackendServiceImpl() {
initialiseCustomers();
}
private static Book createBook(int index) {
final Book book = new Book(bookTitles[index], "Red Penguin", bookPrice[index], 2014, bookAuthors[index]);
return book;
}
private OrderItem createOrderItem() {
int index = random.nextInt(bookTitles.length);
final Book book = bookList.get(index);
final OrderItem orderItem = new OrderItem(book);
final int quantity = random.nextInt(3);
for(int c = 0; c < quantity; c++) {
orderItem.incrementQuantity();
}
return orderItem;
}
private Order createOrder() {
final Order order = new Order();
final int numberOrderItems = random.nextInt(2) + 1;
Set<OrderItem> set = new HashSet<OrderItem>();
int count = set.size();
while(count < numberOrderItems) {
set.add(createOrderItem());
count = set.size();
}
order.setOrderItems(new ArrayList<OrderItem>(set));
final int index = orderIdCounter.getAndIncrement();
order.setOrderId(index);
orders.put(index, order);
return order;
}
private List<Order> createCustomerOrders() {
final int numberOrders = random.nextInt(3) + 1;
final List<Order> orders = new ArrayList<Order>();
for (int index = 0; index < numberOrders; index++) {
orders.add(createOrder());
}
return orders;
}
private int addCustomer(final String firstName, final String lastName, final String email, final String mobileNumber, final String password) {
final Customer customer = new Customer(firstName, lastName, email, mobileNumber, password);
int id = customerIdCounter.incrementAndGet();
customer.setUserId(id);
final List<Order> customerOrders = createCustomerOrders();
for(Order order : customerOrders) {
customer.addOrder(order);
}
customers.put(id, customer);
return id;
}
private void initialiseCustomers() {
addCustomer("homer", "simpson", "[email protected]", "0781 123 456", "marge");
addCustomer("ned", "flanders", "[email protected]", "0781 777 888", "maude");
addCustomer("monty", "burns", "[email protected]", "0781 $$$ $$$", "release the hounds");
}
@Override
public List<Customer> getAllCustomers() {
List<Customer> customersList = new ArrayList<Customer>(customers.values());
return customersList;
}
@Override
public Customer getCustomer(int customerId) {
return customers.get(customerId);
}
@Override
public List<Order> getCustomerOrders(int customerId) {
final Customer customer = customers.get(customerId);
return customer.getOrders();
}
@Override
public Order getOrder(int orderId) {
return orders.get(orderId);
}
public static void main (final String[] args) {
final BackendService service = new BackendServiceImpl();
final Customer customer = service.getCustomer(1);
System.out.println("Customer: " + customer);
}
@Override
public int createCustomer(Customer customer) {
return addCustomer(customer.getForename(), customer.getLastname(), customer.getEmail(), customer.getMobileNumber(), customer.getPassword());
}
@Override
public void deleteCustomer(int id) {
customers.remove(id);
}
}
こんにちは.-幸いです、そして、スタックオーバーフローへようこそ。私はあなたにこれを伝えて申し訳ありませんが、あなたの質問は簡単に答えることができず、あなたはそれを標準にするためにそれを編集する必要があります。 1つは、あなたのコードを全てではなく、[最小限の、完全で、かつ実証可能な例](https://stackoverflow.com/help/mcve)で提供することです。別のこととして、あなたがしようとしていることを正確に記述し、あなたがそれをするときに間違っていることを何とかする必要があります。 –
これがなければ、コード全体を見直して、何をしようとしているのか、そしてどのように間違っているのかを把握し、変更を推奨するように要請しています。これは完全なコードレビューであり、サイト; [ガイダンス](http://stackoverflow.com/help/on-topic)を見てください。 –