Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Thinking and Code of ssm Framework Integration

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Dao layer:

Mybatis integrates spring, creates database connection pool through spring, and manages SqlSessionFactory and mapper proxy objects. Requires an integrated package of mybatis and spring

Create a SqlMapConfig.xml profile

DOCTYPE configuration

PUBLIC "- / / mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

Create applicationContext-dao.xml

To make it easier to change the database, write a db.properties file

Jdbc.driver= database driver

Jdbc.url=jdbc:mysql://localhost:3306/ database name? characterEncoding=utf-8

Jdbc.username= user name

Jdbc.password= password

2. Service layer:

All service implementation classes are managed in a spring container. The practice is managed by spring.

Create applicationContext-service.xml

Create applicationContext-trans.xml

To load the spring container, write the following in Web.Xml

First name

ContextConfigLocation

Classpath:spring/applicationContext*.xml

Org.springframework.web.context.ContextLoaderListener

3. Performance layer:

Springmvc framework, controller managed by springmvc

Create Springmvc.xml

To load the front-end controller (DispatcherServlet), write the following in web.xml

First name

Welcome page

CharacterEncodingFilter

Org.springframework.web.filter.CharacterEncodingFilter

Encoding

Utf-8

CharacterEncodingFilter

/ *

First name

Org.springframework.web.servlet.DispatcherServlet

ContextConfigLocation

Classpath:spring/springmvc.xml

one

Name (just be consistent with the name above)

/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 231

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report