SpringMVC

MVC is a major feature of Spring framework. Spring framework has three major features (IOC (dependency injection), AOP (aspect oriented) and MVC (Modeling M-View V-controller C). Frameworks are typically used for team development, using a layered approach to get everyone to work on different modules, which are then put together to complete the project.

Here is a list of Spring MVC features that speed up development:

Spring MVC provides a DispatchServlet that requires no additional development of xmL-based configuration files used in Spring MVC and can be edited without recompiling the application Spring MVC instantiation controller and constructing beans based on user input. Spring MVC can automatically bind user input and convert data types correctly. For example, Spring MVC can automatically parse strings and set properties of type float or Decimal. Spring MVC validates user input and redirects it back to the input form if it fails. Input validation is optional, programmatic and declarative. Spring MVC is part of the Spring framework to take advantage of the other capabilities that Spring provides. Spring MVC supports internationalization and localization. Support multi-language display by user area Spring MVC supports multiple view technologies. The most common JSP technology and other technologies include Velocity and FreeMarker. Spring is combined with MyBatis, mainly by Spring management database access component Dao, database access component is mainly based on MyBatis implementation. In the Spring environment using MyBatis to achieve database access components process is: first need to introduce a Spring and MyBatis integration development package MyBatis – Spring -1.2.2.jar. Define SqlSessionFactoryBean in the Spring configuration, which is equivalent to SqlSessionFactory being managed in the Spring container. The MapperFactoryBean is defined in the Spring configuration. You can generate a Mapper implementation class interface based on the specified Mapper interface. Spring IOC, Spring AOP, DBCP, Mybatis, driver, Mybatis -spring. Jar Applicationcontext. XML, write the entity class user based on the user table, write usermapper. XML (defining SQL statements), and write the UserMapper interface (mapping with usermapper. XML). The applicationContext. SqlSessionFactoryBean configuration components, in XML Mapper FactoryBean. Finally, test the UserMapperDao instance generated by MapperFactoryBean.

Two features of MyBatis:

1.MyBatis uses SQL and Entity mapping, but does not encapsulate JDBC

2.MyBatis write SQL by itself, more flexible

Here is a brief introduction to JEESZ, SpringMVC, SpringMyBatis integration.

Jeesz is a distributed framework, providing the idea of project modularization, servitization, hot plug, high encapsulation security Java EE rapid development platform.

Jeesz itself integrates Dubbo service management and control, Zookeeper registry, Redis distributed cache technology, FastDFS distributed file system, ActiveMQ asynchronous message middleware, Nginx load balancing and other distributed technologies. Maven is used for project management and project modularization. Improve the ease of development and expansibility of projects

Spring Framework is the core container, Spring MVC is the model view controller, MyBatis is the data access layer, Apache Shiro is the authorization layer, Ehcahe is the cache for common data, And Activit is the workflow engine.

The front end integrates Bootstrap4 Metronic framework, and the UI is responsive and flat layout, which is suitable for all PC, Pad, android, ios mobile devices, etc.

Jeesz is mainly targeted at Internet enterprise architecture, and has built-in basic functions of enterprise information system and efficient code generation tools, including: system permission component, data permission component, data dictionary component, core tool component, view operation component, workflow component, code generation and so on. Adopt layered design, double authentication, secure coding of submitted data, password encryption, access authentication and data permission authentication.

Jeesz currently includes the following module projects: background system management system, RestFul independent service system, Scheduler scheduling system, content management (CMS) system, online Office (OA) system, My To-do (Task Service) and My Collection (Bookmark service).

Background management system includes enterprise organizational structure (user management, organization management, regional management), menu management, role permission management, dictionary management and other functions;

RestFul provides standard Rest service apis. You can quickly implement your own business and provide required services.

Quartz timing scheduling system can dynamically configure your task rules;

Content management (CMS) system, including content management, column management, site management, public message, file management, front-end website display and other functions;

Online office (OA) system, mainly provides simple process instances.

Jeesz provides common tools for encapsulation, including logging tools, caching tools, server-side validation, data dictionaries, current organizational data (users, organizations, regions), and other common gadgets. It also provides a powerful online code generation tool that provides simple single-table, one-to-many, tree-structured functionality that can be used if the appearance requirements are not too high. The Jeesz basic framework is used to improve rapid development efficiency.

SpringMybatis -servlet.xml:

<? xml version="1.0" encoding="UTF-8"? > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
       xmlns:context="http://www.springframework.org/schema/context"  
       xmlns:mvc="http://www.springframework.org/schema/mvc"  
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <! -- Enable spring MVC annotation --> < MVC :annotation-driven> </ MVC :annotation-driven> <! -- Automatically scan the package name to enable Spring to automatically detect components such as annotated Controller--> <context:component-scan base-package="com.alibaba.controller" />  
    <context:component-scan base-package="com.alibaba.service"/ > <! View parser: define the prefix and suffix of the jump file --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">    
        <property name="prefix" value="/WEB-INF/jsp/" />    
        <property name="suffix" value=".jsp"/ > <! </bean> <! < MVC :interceptors> < MVC :interceptor> <! MVC :mapping path="/" />  
            <mvc:mapping path="/user/**" />  
            <mvc:mapping path="/test/**" />  
              
            <bean class="com.alibaba.interceptor.CommonInterceptor"></bean> </mvc:interceptor> <! </ MVC: Interceptors > </beans> </ MVC: Interceptors > </beans>Copy the code

2. Integrate Mybatis

spring-dao.xml:

<? xml version="1.0" encoding="UTF-8"? > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
       xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"  
       xmlns:context="http://www.springframework.org/schema/context"  
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <! <mybatis: Scan base-package= <mybatis:scan base-package= <mybatis:scan base-package= <mybatis:scan base-package="com.alibaba.dao"/ > <! -- Add properties file --> <context:property-placeholder location="classpath:configuration.properties"/ > <! -- database connection --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">   
        <property name="url" value="${jdbc.url}" />  
        <property name="username" value="${jdbc.username}"/>  
        <property name="password" value="${jdbc.password}"/ > <! -- Configure initial size, min, Max --> <property name="initialSize"><value>1</value></property>  
        <property name="maxActive"><value>5</value></property>  
        <property name="minIdle"><value>1</value></property> <! -- Set the timeout for waiting to get connections --> <property name="maxWait"><value>60000</value></property> <! -- Configure the filters for monitoring statistics interception --> <property name="filters"><value>stat</value></property> <! -- Configure how often to check for idle connections to close, in milliseconds --> <property name="timeBetweenEvictionRunsMillis"><value>60000</value></property> <! -- Set the minimum time for a connection to live in the pool, in milliseconds --> <property name="minEvictableIdleTimeMillis"><value>300000</value></property> <! -- <property name="validationQuery"><value>SELECT 'x'</value></property>  
        <property name="testWhileIdle"><value>true</value></property>  
        <property name="testOnBorrow"><value>false</value></property>  
        <property name="testOnReturn"><value>false</value></property>  
        <property name="poolPreparedStatements"><value>true</value></property>  
        <property name="maxOpenPreparedStatements"><value>20</value></property> --> </bean> <! -- Mybatis configuration --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
    </bean>   
</beans>   
Copy the code