diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 98657a7..f50bab9 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,11 +2,13 @@ + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..6dd301c --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/lesson1/src/main/java/homework/AppConfig.java b/lesson1/src/main/java/ru/geekbrains/homework/AppConfig.java similarity index 84% rename from lesson1/src/main/java/homework/AppConfig.java rename to lesson1/src/main/java/ru/geekbrains/homework/AppConfig.java index b679a03..aee0779 100644 --- a/lesson1/src/main/java/homework/AppConfig.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/AppConfig.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/lesson1/src/main/java/homework/Clinic.java b/lesson1/src/main/java/ru/geekbrains/homework/Clinic.java similarity index 97% rename from lesson1/src/main/java/homework/Clinic.java rename to lesson1/src/main/java/ru/geekbrains/homework/Clinic.java index 12d2513..bde2eff 100644 --- a/lesson1/src/main/java/homework/Clinic.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/Clinic.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/lesson1/src/main/java/homework/ClinicPlan.java b/lesson1/src/main/java/ru/geekbrains/homework/ClinicPlan.java similarity index 90% rename from lesson1/src/main/java/homework/ClinicPlan.java rename to lesson1/src/main/java/ru/geekbrains/homework/ClinicPlan.java index 150f1cd..3e07324 100644 --- a/lesson1/src/main/java/homework/ClinicPlan.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/ClinicPlan.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; diff --git a/lesson1/src/main/java/homework/DoctorSchedule.java b/lesson1/src/main/java/ru/geekbrains/homework/DoctorSchedule.java similarity index 91% rename from lesson1/src/main/java/homework/DoctorSchedule.java rename to lesson1/src/main/java/ru/geekbrains/homework/DoctorSchedule.java index e825bff..5f099f6 100644 --- a/lesson1/src/main/java/homework/DoctorSchedule.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/DoctorSchedule.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; diff --git a/lesson1/src/main/java/homework/Human.java b/lesson1/src/main/java/ru/geekbrains/homework/Human.java similarity index 93% rename from lesson1/src/main/java/homework/Human.java rename to lesson1/src/main/java/ru/geekbrains/homework/Human.java index 8b148c4..f25a017 100644 --- a/lesson1/src/main/java/homework/Human.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/Human.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/lesson1/src/main/java/homework/MedicalCard.java b/lesson1/src/main/java/ru/geekbrains/homework/MedicalCard.java similarity index 62% rename from lesson1/src/main/java/homework/MedicalCard.java rename to lesson1/src/main/java/ru/geekbrains/homework/MedicalCard.java index 989e16c..6c6dd1f 100644 --- a/lesson1/src/main/java/homework/MedicalCard.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/MedicalCard.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; public interface MedicalCard { void doShow(); diff --git a/lesson1/src/main/java/homework/MedicalInstitution.java b/lesson1/src/main/java/ru/geekbrains/homework/MedicalInstitution.java similarity index 67% rename from lesson1/src/main/java/homework/MedicalInstitution.java rename to lesson1/src/main/java/ru/geekbrains/homework/MedicalInstitution.java index 10af518..84de697 100644 --- a/lesson1/src/main/java/homework/MedicalInstitution.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/MedicalInstitution.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; public interface MedicalInstitution { void visitDoctor(); diff --git a/lesson1/src/main/java/homework/PatientMedicalCard.java b/lesson1/src/main/java/ru/geekbrains/homework/PatientMedicalCard.java similarity index 94% rename from lesson1/src/main/java/homework/PatientMedicalCard.java rename to lesson1/src/main/java/ru/geekbrains/homework/PatientMedicalCard.java index 191ad05..615f803 100644 --- a/lesson1/src/main/java/homework/PatientMedicalCard.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/PatientMedicalCard.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; diff --git a/lesson1/src/main/java/homework/Plan.java b/lesson1/src/main/java/ru/geekbrains/homework/Plan.java similarity index 58% rename from lesson1/src/main/java/homework/Plan.java rename to lesson1/src/main/java/ru/geekbrains/homework/Plan.java index 7478537..6c8d601 100644 --- a/lesson1/src/main/java/homework/Plan.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/Plan.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; public interface Plan { void doShow(); diff --git a/lesson1/src/main/java/homework/Schedule.java b/lesson1/src/main/java/ru/geekbrains/homework/Schedule.java similarity index 60% rename from lesson1/src/main/java/homework/Schedule.java rename to lesson1/src/main/java/ru/geekbrains/homework/Schedule.java index c324838..7ad790a 100644 --- a/lesson1/src/main/java/homework/Schedule.java +++ b/lesson1/src/main/java/ru/geekbrains/homework/Schedule.java @@ -1,4 +1,4 @@ -package homework; +package ru.geekbrains.homework; public interface Schedule { void doShow(); diff --git a/lesson2/pom.xml b/lesson2/pom.xml new file mode 100644 index 0000000..eb1bba1 --- /dev/null +++ b/lesson2/pom.xml @@ -0,0 +1,95 @@ + + + + + base-spring-framework + ru.geekbrains + 1.0-SNAPSHOT + + 4.0.0 + + lesson2 + war + + lesson2 Maven Webapp + + http://www.example.com + + + UTF-8 + 1.8 + 1.8 + + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + org.slf4j + slf4j-api + 1.7.32 + provided + + + + org.projectlombok + lombok + 1.18.22 + + + + junit + junit + 4.13.2 + test + + + + + lesson2 + + + + org.wildfly.plugins + wildfly-maven-plugin + 2.0.1.Final + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-war-plugin + 3.2.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + + diff --git a/lesson2/src/main/java/ru/geekbrains/homework/Product.java b/lesson2/src/main/java/ru/geekbrains/homework/Product.java new file mode 100644 index 0000000..c109feb --- /dev/null +++ b/lesson2/src/main/java/ru/geekbrains/homework/Product.java @@ -0,0 +1,14 @@ +package ru.geekbrains.homework; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +@AllArgsConstructor +@Getter +@ToString +public class Product { + private int id; + private String title; + private double cost; +} diff --git a/lesson2/src/main/java/ru/geekbrains/homework/ProductList.java b/lesson2/src/main/java/ru/geekbrains/homework/ProductList.java new file mode 100644 index 0000000..018fc0c --- /dev/null +++ b/lesson2/src/main/java/ru/geekbrains/homework/ProductList.java @@ -0,0 +1,37 @@ +package ru.geekbrains.homework; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@WebServlet(name = "ProductList", urlPatterns = "/product_list") +public class ProductList extends HttpServlet { + + private static Logger logger = LoggerFactory.getLogger(ProductList.class); + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + logger.info("Method doGet"); + + List list = new ArrayList<>(); + for (int i = 1; i < 11; i++) { + list.add(new Product(i, "Product" + i, i)); + } + + req.setAttribute("products", list); + +// System.out.println(list); + + RequestDispatcher dispatcher = req.getRequestDispatcher("view/product_list.jsp"); + dispatcher.forward(req, resp); + } +} diff --git a/lesson2/src/main/webapp/WEB-INF/web.xml b/lesson2/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..a105770 --- /dev/null +++ b/lesson2/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,8 @@ + + + + Archetype Created Web Application + \ No newline at end of file diff --git a/lesson2/src/main/webapp/index.jsp b/lesson2/src/main/webapp/index.jsp new file mode 100644 index 0000000..c38169b --- /dev/null +++ b/lesson2/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + diff --git a/lesson2/src/main/webapp/view/product_list.jsp b/lesson2/src/main/webapp/view/product_list.jsp new file mode 100644 index 0000000..3e935b3 --- /dev/null +++ b/lesson2/src/main/webapp/view/product_list.jsp @@ -0,0 +1,15 @@ +<%@ page import="java.util.List" %> +<%@ page import="ru.geekbrains.homework.Product" %> + + +

Product list

+<% + List list = (List) request.getAttribute("products"); + out.println(""); + for (Product product: list) { + out.println("
  • " + product + "
  • "); + } + out.println("
    "); +%> + + diff --git a/pom.xml b/pom.xml index 5ddf33a..5e2bbfa 100644 --- a/pom.xml +++ b/pom.xml @@ -10,6 +10,7 @@ 1.0-SNAPSHOT lesson1 + lesson2