About using SSM (Spring-springmvc-mybatis) to develop basic ideas

Source: Internet
Author: User

Demand analysis

program = data structure + algorithm

Storage of design data
    1. Memory: Temporary data storage location, power off will disappear, called transient

      • Running memory
      • Assigned is an object
    2. External memory: (SSD solid hard disk, HDD mechanical HDD, SD, Flash, USB stick), power off does not disappear, called persistent state

      • Storage capacity
      • Saved is a single-file (single-threaded) program that can use files to store data
      • Database (file) database management system, providing concurrent access management! For multithreaded access

Programming Ideas:

    1. Understand the business needs.
    2. Consider how data is stored.
    3. How to manipulate data to achieve business purpose
      • Design SQL
    4. Programming: Integrating business functions and data operations, programming to execute SQL Operations data

For example:Environment construction
  • Create a MAVEN project
  • Build Web. xml
  • Import target Run Environment: Tomcat Run environment
  • Import the package you want: Pom.xml

    <dependency> <groupId>org.springframework</groupId> <artifactid>spring-webmvc</ Artifactid> <version>3.2.8.RELEASE</version></dependency><dependency> <groupId> Com.fasterxml.jackson.core</groupid> <artifactId>jackson-annotations</artifactId> <version >2.2.3</version></dependency><dependency> <groupid>com.fasterxml.jackson.core</ Groupid> <artifactId>jackson-core</artifactId> <version>2.2.3</version></ Dependency><dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>    Jackson-databind</artifactid> <version>2.2.3</version></dependency><dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8< /version></dependency><dependency> <groupId>org.mybatis</groupid> <artifactId>mybatis-spring</artifactId> <version>1.2.3</version></ Dependency><dependency> <groupId>org.springframework</groupId> <artifactId> Spring-jdbc</artifactid> <version>3.2.8.release</version></dependency><dependency > <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version&gt ;1.4</version></dependency><dependency> <groupId>junit</groupId> <artifactid >junit</artifactId> <version>4.12</version></dependency><dependency> < Groupid>mysql</groupid> <artifactId>mysql-connector-java</artifactId> <version>5.1.6 </version></dependency>
  • Configure Spring MVC Controller: Web. XML

      <servlet> <description></description> <display- Name>dispatcherservlet</display-name> <servlet-name>DispatcherServlet</servlet-name> < Servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> < Description></description> <param-name>contextConfigLocation</param-name> <PARAM-VALUE&G T;classpath:conf/spring-*.xml</param-value> </init-param> <load-on-startup>1</ load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherservlet</ Servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>  
  • Add SPRING-MVC configuration file: Conf/spring-mvc.xml

    <!-- 配置组件扫描 --><context:component-scan     base-package="com.xx"/><!-- 配置MVC注解扫描 --><mvc:annotation-driven />
  • Add database connection parameter file: conf/jdbc.properties:

    driver=com.mysql.jdbc.Driver
    url=jdbc:mysql://localhost:3306/xxx
    user=root
    password=root

(These 4 rows store the database driver information, the URL, the user name and password to connect to the login database, respectively.) )

  • Configure Mybatis:conf/spring-mybatis.xml

    <!--Configure Spring-mybatis.xml--><!--read configuration file--><util:properties id= "jdbc" location= "classpath:conf/ Jdbc.properties "/> <!--configuration database connection pool--><bean id=" DataSource "class=" Org.apache.commons.dbcp.BasicDataSource "destroy-method=" Close "> <property name=" driverclassname "Valu        E= "#{jdbc.driver}"/> <property name= "url" value= "#{jdbc.url}"/> <property name= "username" Value= "#{jdbc.user}"/> <property name= "password" value= "#{jdbc.password}"/> <property name= "maxAc tive "value=" #{jdbc.maxactive} "></property></bean><!--configuration mybatis sessionfactory--><bean I D= "Sqlsessionfactory" class= "Org.mybatis.spring.SqlSessionFactoryBean" > <property name= "DataSource" re f= "DataSource"/> <property name= "mapperlocations" value= "Classpath:mapper/*.xml"/></bean><!-- Mapper interface Components scan--><bean class= "Org.mybatis.spring.mapper.MapperScanneRconfigurer "> <property name=" basepackage "value=" Org.mybatis.spring.sample.mapper "/></bean> 

The above content is oneself in the writing SSM frame is oneself according to the code summary, dare not guarantee hundred correct, approximate idea is like this, still want to keep summing up to find the mistake to correct in time.

About using SSM (Spring-springmvc-mybatis) to develop basic ideas

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.