柚子快报激活码778899分享:简单的SSM框架搭建教程

http://www.51969.com/

简单的ssm框架的搭建和配置文件

ssm框架里边的配置:

1.src路径下直接存放数据库和log4j的properties文件

2.src路径下建个config包,分别放置ssm的xml文件

3.修改WEB-INF路径下的web.xml

4.注意放置配置文件的路径问题

1.src路径下的jdbc.propreties和log4j.properties

log4j.properties

log4j.properties里边的代码,例如:

# Global logging configuration

log4j.rootLogger=DEBUG, stdout

# Console output...

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

jdbc.properties

jdbc.properties里边的代码,例如:

1 # Global logging configuration

2 jdbc.driverClassName=com.mysql.jdbc.Driver

3 jdbc.url=jdbc:mysql:///ssm_my?useUnicode=true&characterEncoding=utf8

4 jdbc.username=root

5 jdbc.password=root

2.src路径下建个config包,分别放置ssm的xml文件

applicationContext.xml

spring框架里边applicationContext.xml配置文件的代码,例如:

1

2

3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"

4 xmlns:context="http://www.springframework.org/schema/context"

5 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

6 xsi:schemaLocation="http://www.springframework.org/schema/beans

7 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd

8 http://www.springframework.org/schema/context

9 http://www.springframework.org/schema/context/spring-context-4.3.xsd

10 http://www.springframework.org/schema/aop

11 http://www.springframework.org/schema/aop/spring-aop.xsd

12 http://www.springframework.org/schema/tx

13 http://www.springframework.org/schema/tx/spring-tx.xsd">

14

15

16

17 expression="org.springframework.stereotype.Controller" />

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

42

43

44

45

46

47

48 read-only="true" />

49

50 read-only="false" />

51

52

53

54

55

56 id="poit" />

57

58

59

springmvc-servlet.xml

springmvc框架里边springmvc-servlet.xml配置文件的代码,例如:

1

2

3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"

4 xmlns:context="http://www.springframework.org/schema/context"

5 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

6 xmlns:mvc="http://www.springframework.org/schema/mvc"

7 xsi:schemaLocation="http://www.springframework.org/schema/beans

8 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd

9 http://www.springframework.org/schema/context

10 http://www.springframework.org/schema/context/spring-context-4.3.xsd

11 http://www.springframework.org/schema/aop

12 http://www.springframework.org/schema/aop/spring-aop.xsd

13 http://www.springframework.org/schema/tx

14 http://www.springframework.org/schema/tx/spring-tx.xsd

15 http://www.springframework.org/schema/mvc

16 http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">

17

18

19 class="org.springframework.web.servlet.view.InternalResourceViewResolver">

20

21 value="org.springframework.web.servlet.view.JstlView">

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37 .js

38 .css

39 .png

40 .gif

41 .jsp

42

43

44

45

46

47

48

SqlMapConfig.xml

mybatis框架里边SqlMapConfig.xml配置文件的代码,例如:

1

2

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

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

5

6

7

8

9

10

11

12

13

14

15

16

17

3.修改WEB-INF路径下的web.xml

WEB-INF路径下的web.xml

WEB-INF路径下的web.xml的代码,例如:

1

2

3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

4 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

5 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

6

7 ssm

8

9

10 views/login.jsp

11

12

13

14

15 CharacterEncodingFilter

16 org.springframework.web.filter.CharacterEncodingFilter

17

18 encoding

19 utf-8

20

21

22

23 CharacterEncodingFilter

24 /*

25

26

27

28

29 springmvc

30 org.springframework.web.servlet.DispatcherServlet

31

32 contextConfigLocation

33 classpath:config/springmvc-servlet.xml

34

35

36

37 springmvc

38 /

39

40

41

42

43 org.springframework.web.context.ContextLoaderListener

44

45

46

47 contextConfigLocation

48 classpath:config/applicationContext.xml

49

50

51

4.注意放置配置文件的路径问题

柚子快报激活码778899分享:简单的SSM框架搭建教程

http://www.51969.com/

查看原文