博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
基于SSM的后台管理系统总结
阅读量:2389 次
发布时间:2019-05-10

本文共 10618 字,大约阅读时间需要 35 分钟。

文章目录

资源地址

首先分享自己的成果,在这里给出项目的资源链接:
https://github.com/capriciousness/tourism_management.git

SSM环境搭建

环境准备

1.1 数据库与表结构

创建用户与授权

数据库我们使用Oracle Oracle 为每个项目创建单独user,oracle数据表存放在表空间下,每个用户有独立表空间

  • 创建用户及密码:
语法[创建用户]: create user 用户名 identified by 口令[即密码]; 例子: create user test identified by test;
  • 授权
语法: grant connect, resource to 用户名; 例子: grant connect, resource to
  • 连接oracle数据库

PL/SQL Developer是一个集成开发环境,专门面向Oracle数据库存储程序单元的开发PL/SQL Developer侧重于易 用性、代码品质和生产力,充分发挥Oracle应用程序开发过程中的主要优势。

在这里插入图片描述

  • 创建用户及授权
    a) 创建用户
    在这里插入图片描述
    b) 授权
    在这里插入图片描述
    对象权限是指针对于某一张表的操作权限,系统权限是指对表的CRUD操作权限, 角色权限是系统权限的集合,我们设置 时,一般是设置角色权限,设置resource与connect

创建表

CREATE TABLE product(id varchar2(32) default SYS_GUID() PRIMARY KEY,productNum VARCHAR2(50) NOT NULL,productName VARCHAR2(50),cityName VARCHAR2(50),DepartureTime timestamp,productPrice Number,productDesc VARCHAR2(500),productStatus INT,CONSTRAINT product UNIQUE (id, productNum))insert into PRODUCT (id, productnum, productname, cityname, departuretime, productprice, productdesc, productstatus)values ('676C5BD1D35E429A8C2E114939C5685A', 'itcast-002', '北京三日游', '北京', to_timestamp('10-10-2018 10:10:00.000000', 'dd-mm-yyyy hh24:mi:ss.ff'), 1200, '不错的旅行', 1);insert into PRODUCT (id, productnum, productname, cityname, departuretime, productprice, productdesc, productstatus)values ('12B7ABF2A4C544568B0A7C69F36BF8B7', 'itcast-003', '上海五日游', '上海', to_timestamp('25-04-2018 14:30:00.000000', 'dd-mm-yyyy hh24:mi:ss.ff'), 1800, '魔都我来了', 0);insert into PRODUCT (id, productnum, productname, cityname, departuretime, productprice, productdesc, productstatus)values ('9F71F01CB448476DAFB309AA6DF9497F', 'itcast-001', '北京三日游', '北京', to_timestamp('10-10-2018 10:10:00.000000', 'dd-mm-yyyy hh24:mi:ss.ff'), 1200, '不错的旅行', 1);

1.2 maven工程搭建(pom)

4.0.0
com.itheima.heima_ssm
heima_ssm
pom
1.0-SNAPSHOT
5.0.2.RELEASE
1.6.6
1.2.12
5.1.32
3.4.5
5.0.1.RELEASE
org.aspectj
aspectjweaver
1.6.8
org.springframework
spring-aop
${spring.version}
org.springframework
spring-context
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-orm
${spring.version}
org.springframework
spring-beans
${spring.version}
org.springframework
spring-core
${spring.version}
org.springframework
spring-test
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-tx
${spring.version}
junit
junit
4.12
test
javax.servlet
javax.servlet-api
3.1.0
provided
javax.servlet.jsp
jsp-api
2.0
provided
jstl
jstl
1.2
log4j
log4j
${log4j.version}
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.3.0
c3p0
c3p0
0.9.1.2
jar
compile
com.github.pagehelper
pagehelper
5.1.2
org.springframework.security
spring-security-web
${spring.security.version}
org.springframework.security
spring-security-config
${spring.security.version}
org.springframework.security
spring-security-core
${spring.security.version}
org.springframework.security
spring-security-taglibs
${spring.security.version}
mysql
mysql-connector-java
${mysql.version}
javax.annotation
jsr250-api
1.0
org.apache.maven.plugins
maven-compiler-plugin
3.5
1.8
1.8
UTF-8
true
heima_ssm_dao
heima_ssm_service
heima_ssm_domain
heima_ssm_utils
heima_ssm_web

1.3编写实体类

public class Product {
private String id; // 主键private String productNum; // 编号 唯一private String productName; // 名称private String cityName; // 出发城市private Date departureTime; // 出发时间private String departureTimeStr;private double productPrice; // 产品价格private String productDesc; // 产品描述private Integer productStatus; // 状态 0 关闭 1 开启 private String productStatusStr;}

编写接口

  • 业务
public interface IProductService {
List
findAll() throws Exception;}
  • 持久层
public interface IProductDao {
@Select("select * from product")List
findAll() throws Exception;}

SSM整合(web)与产品查询

在这里插入图片描述

Spring环境搭建

2.1.1.编写Spring配置文件applicationContext.xml

Spring与MyBatis整合

把 mybatis 配置文件(mybatis.xml)中内容配置到 spring 配置文件中 同时,把 mybatis 配置文件的内容清掉。

由于我们使用的是代理 Dao , 的模式,Dao 具体实现类由 MyBatis 使用代理方式创建,所以此时 mybatis 配置文件不能删。 当我们整合 spring 和 mybatis 时,mybatis 创建的 Mapper.xml 文件名必须和 Dao 接口 文件 名一致

2.1.2.使用注解配置业务层

@Servicepublic class ProductServiceImpl implements IProductService{
@Overridepublic List
findAll() throws Exception {
return null;}}

web.xml 配置

contextConfigLocation
classpath*:applicationContext.xml,classpath*:spring-security.xml
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.request.RequestContextListener
dispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:springmvc.xml
1
dispatcherServlet
*.do
characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
characterEncodingFilter
/*
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp

Spring MVC 环境搭建

  • 2.2.2.Spring MVC配置文件springmvc.xml
  • 2.2.3.编写ProductController
@Controller@RequestMapping("/product")public class ProductController {
@Autowiredprivate IProductService productService;@RequestMapping("/findAll.do")public ModelAndView findAll() {
return null;}}

测试运行

http://localhost:8888/heima_ssm_web/product/findAll.do

  • index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
主页查询产品信息

在这里插入图片描述

转载地址:http://exxab.baihongyu.com/

你可能感兴趣的文章
《云计算架构技术与实践》连载(2):1.2 云计算的发展趋势
查看>>
《跨界杂谈》企业商业模式(七):其他
查看>>
STL介绍 - map
查看>>
ssh 命令的用法
查看>>
scp 命令的用法
查看>>
ldcofig 命令的用法
查看>>
tar 命令的用法
查看>>
mount 命令的用法
查看>>
fdisk 命令的用法
查看>>
ln 命令的用法
查看>>
ORACLE的归档空间满导致的监听故障数据库无法启动
查看>>
GRID卸载及重新安装
查看>>
shell 带参数脚本
查看>>
QTcpSocket 编程
查看>>
java 开发环境配置
查看>>
java bufferedreader 与inputstream的区别
查看>>
Jsp页面Word文档的生成
查看>>
二叉树的构建及遍历 Java实现
查看>>
xml schema约束 学习记录
查看>>
线索二叉树(中序) Java实现
查看>>