├── README.md ├── .idea ├── vcs.xml ├── modules.xml ├── artifacts │ ├── usersystem_war.xml │ └── usersystem_war_exploded.xml ├── libraries │ ├── Maven__antlr_antlr_2_7_7.xml │ ├── Maven__dom4j_dom4j_1_6_1.xml │ ├── Maven__xml_apis_xml_apis_1_0_b2.xml │ ├── Maven__org_jboss_jandex_1_1_0_Final.xml │ ├── Maven__org_javassist_javassist_3_18_1_GA.xml │ ├── Maven__commons_logging_commons_logging_1_2.xml │ ├── Maven__org_jboss_logging_jboss_logging_3_1_3_GA.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_5_0.xml │ ├── Maven__org_hibernate_hibernate_core_4_3_3_Final.xml │ ├── Maven__org_codehaus_jackson_jackson_core_asl_1_9_13.xml │ ├── Maven__org_springframework_spring_aop_4_3_5_RELEASE.xml │ ├── Maven__org_springframework_spring_web_4_3_5_RELEASE.xml │ ├── Maven__org_springframework_spring_core_4_3_5_RELEASE.xml │ ├── Maven__org_codehaus_jackson_jackson_mapper_asl_1_9_13.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_5_0.xml │ ├── Maven__org_springframework_spring_beans_4_3_5_RELEASE.xml │ ├── Maven__org_springframework_spring_webmvc_4_3_5_RELEASE.xml │ ├── Maven__org_springframework_spring_context_4_3_5_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_0.xml │ ├── Maven__org_hibernate_hibernate_entitymanager_4_3_3_Final.xml │ ├── Maven__org_springframework_spring_expression_4_3_5_RELEASE.xml │ ├── Maven__org_jboss_logging_jboss_logging_annotations_1_2_0_Beta1.xml │ ├── Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_0_Final.xml │ ├── Maven__org_hibernate_common_hibernate_commons_annotations_4_0_4_Final.xml │ └── Maven__org_jboss_spec_javax_transaction_jboss_transaction_api_1_2_spec_1_0_0_Final.xml ├── misc.xml ├── compiler.xml └── uiDesigner.xml ├── src └── main │ ├── webapp │ └── WEB-INF │ │ ├── pages │ │ ├── users_page.jsp │ │ ├── test.jsp │ │ └── users_check_page.jsp │ │ ├── web.xml │ │ └── spring │ │ └── spring-config.xml │ └── java │ └── system │ ├── dao │ └── UserDao.java │ ├── service │ └── UserService.java │ ├── model │ └── User.java │ └── controller │ └── UserController.java ├── pom.xml └── usersystem.iml /README.md: -------------------------------------------------------------------------------- 1 | # usersystem 2 | Simple Spring MVC application sample presented by Hillel IT school teacher. 3 | Its code based on the [video](https://www.youtube.com/watch?v=Z9dvZyEofAg). 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/artifacts/usersystem_war.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/pages/users_page.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: Max 4 | Date: 16.07.2017 5 | Time: 15:50 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 12 | 13 | 14 | Hello from spring 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/pages/test.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: Max 4 | Date: 16.07.2017 5 | Time: 16:27 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Test 12 | 13 | 14 | test... 15 | test... 16 | test... 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__antlr_antlr_2_7_7.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/system/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package system.dao; 2 | 3 | import org.springframework.stereotype.Repository; 4 | import system.model.User; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Max on 16.07.2017. 11 | */ 12 | 13 | @Repository 14 | public class UserDao { 15 | private List users = Arrays.asList( 16 | new User("admin", "admin"), 17 | new User("user1", "user1")); 18 | 19 | public List getAllUsers() { 20 | return users; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/system/service/UserService.java: -------------------------------------------------------------------------------- 1 | package system.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import system.dao.UserDao; 6 | import system.model.User; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by Max on 16.07.2017. 12 | */ 13 | 14 | @Service 15 | public class UserService { 16 | @Autowired 17 | private UserDao userDao; 18 | 19 | public List getAllUsers() { 20 | return userDao.getAllUsers(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__xml_apis_xml_apis_1_0_b2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jboss_jandex_1_1_0_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_javassist_javassist_3_18_1_GA.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_1_3_GA.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hibernate_hibernate_core_4_3_3_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_codehaus_jackson_jackson_core_asl_1_9_13.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_aop_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_web_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_core_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_codehaus_jackson_jackson_mapper_asl_1_9_13.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_beans_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/pages/users_check_page.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Max 5 | Date: 16.07.2017 6 | Time: 15:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | 17 | 18 | check user 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hibernate_hibernate_entitymanager_4_3_3_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_expression_4_3_5_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jboss_logging_jboss_logging_annotations_1_2_0_Beta1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_0_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_4_0_4_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jboss_spec_javax_transaction_jboss_transaction_api_1_2_spec_1_0_0_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | dispatcher 10 | org.springframework.web.servlet.DispatcherServlet 11 | 12 | contextConfigLocation 13 | /WEB-INF/spring/spring-config.xml 14 | 15 | 1 16 | 17 | 18 | 19 | dispatcher 20 | / 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/system/model/User.java: -------------------------------------------------------------------------------- 1 | package system.model; 2 | 3 | /** 4 | * Created by Max on 16.07.2017. 5 | */ 6 | public class User { 7 | private String name; 8 | private String password; 9 | 10 | public User() { 11 | 12 | } 13 | 14 | public User(String name, String password) { 15 | this.name = name; 16 | this.password = password; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "User{" + 38 | "name='" + name + '\'' + 39 | ", password='" + password + '\'' + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/spring/spring-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/java/system/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package system.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.ModelAttribute; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import org.springframework.web.servlet.ModelAndView; 10 | import system.model.User; 11 | import system.service.UserService; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Max on 16.07.2017. 17 | */ 18 | 19 | @Controller 20 | @RequestMapping("/users") 21 | public class UserController { 22 | @Autowired 23 | private UserService userService; 24 | 25 | @RequestMapping(value = "/list", method = RequestMethod.GET) 26 | public @ResponseBody 27 | List getAllUsers() { 28 | return userService.getAllUsers(); 29 | } 30 | 31 | @RequestMapping(value = "/validate", method = RequestMethod.GET) 32 | public ModelAndView validateUser() { 33 | ModelAndView modelAndView = new ModelAndView(); 34 | modelAndView.addObject("userFromServer", new User()); 35 | modelAndView.setViewName("users_check_page"); 36 | return modelAndView; 37 | } 38 | 39 | @RequestMapping(value = "/check", method = RequestMethod.POST) 40 | public @ResponseBody 41 | String checkUser(@ModelAttribute("userFromServer") User user) { 42 | if ("admin".equals(user.getName()) && "admin".equals(user.getPassword())) { 43 | return "valid"; 44 | } 45 | return "invalid"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | user-system 8 | user-system 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | 13 | 14 | org.springframework 15 | spring-core 16 | 4.3.5.RELEASE 17 | 18 | 19 | org.springframework 20 | spring-context 21 | 4.3.5.RELEASE 22 | 23 | 24 | org.springframework 25 | spring-beans 26 | 4.3.5.RELEASE 27 | 28 | 29 | org.springframework 30 | spring-web 31 | 4.3.5.RELEASE 32 | 33 | 34 | org.springframework 35 | spring-webmvc 36 | 4.3.5.RELEASE 37 | 38 | 39 | org.hibernate 40 | hibernate-core 41 | 4.3.3.Final 42 | 43 | 44 | org.hibernate 45 | hibernate-entitymanager 46 | 4.3.3.Final 47 | 48 | 49 | com.fasterxml.jackson.core 50 | jackson-databind 51 | 2.5.0 52 | 53 | 54 | org.codehaus.jackson 55 | jackson-mapper-asl 56 | 1.9.13 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.eclipse.jetty 64 | jetty-maven-plugin 65 | 9.2.11.v20150529 66 | 67 | 68 | 10 69 | 70 | 9999 71 | 72 | 73 | /user-system 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /.idea/artifacts/usersystem_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target/user-system-1.0-SNAPSHOT 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /usersystem.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | --------------------------------------------------------------------------------