Код: Выделить всё
public class ContactBusiness {
public List getContactList() {
List listContact = new ArrayList();
listContact.add(new Contact("Marry John", "marry.john@gmail.com", "USA"));
listContact.add(new Contact("Tom Smith", "tomsmith@outlook.com", "England"));
listContact.add(new Contact("John Purcell", "john123@yahoo.com", "Australia"));
listContact.add(new Contact("Siva Krishna", "sivakrishna@gmail.com", "India"));
return listContact;
}
}
< /code>
Это получено с помощью этого контроллера: < /p>
@Controller
@RequestMapping("/")
public class AppController {
@RequestMapping("/list_contact")
public String listContact(Model model) {
ContactBusiness business = new ContactBusiness();
List contactList = business.getContactList();
model.addAttribute("contacts", contactList);
return "contact";
}
}
< /code>
У меня довольно простой pojo: < /p>
public class Contact {
private String name;
private String email;
private String country;
public Contact() {
super();
}
public Contact(String name, String email, String country) {
super();
this.name = name;
this.email = email;
this.country = country;
}
// Getters & Setters
}
Код: Выделить всё
My Contacts - Spring Boot Web Application Example
My Contacts
[url=/list_contact]Click here to list all contacts[/url]
< /code>
Приложение запускается. В журнале я вижу, что Tomcat o.s.b.w.embedded.tomcat.tomcatwebserver: tomcat начал на порте 8089 (http) с контекстным путем '/'
Страница ошибок Whitelabel < /p>
Это приложение не имеет явного картирования. 2025
Была неожиданная ошибка (type = не найдено, status = 404). < /P>
< /blockquote>
Это мой контакт.jsp: < /p>
Код: Выделить всё
Contact List - Spring Boot Web Application Example
My Contact List
NameEmailCountry
${contact.name}
${contact.email}
${contact.country}
Код: Выделить всё
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
resourcehandlerutils: «Путь с" web-inf "или" meta-inf ": [web-inf/jsp/contact.jsp]"
Подробнее здесь: https://stackoverflow.com/questions/797 ... pplication
Мобильная версия