创建工程键值设置 [防止加载过慢]archetypeCatalog = internal
1 | <dependency> |
新建java文件夹和resource文件夹 mark dici as ROOT、Resource
新建包(package)
org.test.controller 、org.test.service 、org.test.domain、 org.test.dao
具体实现demo 类与接口
org.test.controller.UserController
1 | package org.test.controller; |
org.test.dao.UserDao
1 | package org.test.dao; |
org.test.domain.User
1 | package org.test.domain; |
org.test.service.AccountService
1 | package org.test.service; |
org.test.service.impl.UserServiceImpl
1 | package org.test.service.impl; |
新建Spring-XML文件(Resource)
applicationContext.xml
1 |
|
Spring约束开注解扫描
1 | <context:component-scan base-package="org.test"> |
给Service注解让其实例交给IOC(src/main/java/org/test/service/impl/UserServiceImpl.java:8)
1 | @Service("userService") |
加log4j.propeties(防止异常)
1 | debug,stdout,info,debug,warn,error = |
连接SpringMVC
web.xml
1 |
|
连接SpringMVC–配置springmvc.xml
1 |
|
两个表现层的jsp
index.jsp
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
pages/list.jsp
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> |
加测试文件(可省略)
E:\Desktop\ssm\src\main\java\test\TestSpring.java
1 | package test; |
E:\Desktop\ssm\src\main\java\test\TestSpring.java
1 | package test; |