java版云笔记(一)
云笔记项目
这个项目的sql文件,需求文档,需要的html文件,jar包都可以去下载,下载地址为:http://download.csdn.net/download/liveor_die/9985846
项目简介
笔记管理系统,用户可以管理笔记信息,可以查看
其他用户分享的笔记.
主要功能如下
- 用户模块:登录、注册、修改密码、退出
- 笔记本模块:创建、删除、更新、查看
- 笔记模块:创建、删除、更新、查看、转移
- 分享和收藏模块:分享、收藏、查看、搜索分享
- 回收站模块:查看、彻底删除、恢复
- 活动模块:查看活动、参加活动等
项目整体设计
使用的主要技术
jQuery、Ajax、SpringMVC、IOC、AOP、MyBatis
- jQuery:简化前端javascript和ajax编程
- Ajax:页面局部处理;提升用户体验和性能
- SpringMVC:负责接收请求,调用业务组件处理,
将结果生成JSON响应输出 - SpringIOC:负责管理Controller,Service,Dao;维护这些组件对象之间的关系
- MyBatis:负责实现数据库操作,实现Dao
- SpringAOP:负责事务和异常日志功能切入。
(不用修改原有组件代码,就可以追加功能)
项目整体规范
-所有请求采用Ajax方式交互
(使用$.ajax()函数)
-系统页面全部采用HTML
(替代JSP+JSTL+EL)
-所有请求服务器处理完返回的JSON结果格式
如下
{"status":xx,"msg":xxx,"data":xxx}
表现层--》控制层--》业务层--》持久层/数据访问层
HTML(ajax)-->Controller-->Service-->Dao
响应流程
Ajax+SpringMVC+Spring(IOC/AOP)+MyBatis
Ajax-->SpringMVC-->返回JSON结果
JSP响应流程
**请求-->DispatcherServlet--> HandlerMapping--> Controller-- 返回ModelAndView/String--> ViewResolver--> JSP -->响应
**
JSON响应流程
请求-->DispatcherServlet--> HandlerMapping--> Controller--> 返回数据对象(int,User,List,Map)--> 引入jackson包,在Controller方法前添加@ResponseBody标记--> JSON响应
搭建环境
创建mysql数据库,名字为:cloud_note,编码格式为utf-8
数据库文件下载地址:
mysql常用数据库语句
- show databases;//查看有哪些库
- use 库名;//使用某个库
- show tables;//查看库里有哪些表
- desc 表名;//查看表结构
- source sql文件;//导入sql文件
导入项目数据库步骤
-set names utf8;
-source D:\cloud_note.sql;
详细的关于mysql的sql可以看我的关于mysql的博客。
创建maven web项目
项目名字为:cloud_note
需要引入的包
- spring-webmvc包
- mybatis包
- dbcp包+MySQL驱动包
- jackson包
- mybatis-spring.jar
- junit包
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.3</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>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
</dependencies>
配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>cloud_note</display-name>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<!-- dispatcherServlet的初始化方法会启动
spring容器,所以需要告诉它spring配置文件的位置
注意:默认情况下,如果没有配置contextconfiglocation(既没有指定spring指定配置
文件的位置则会查找web-inf/servletname-servlet.xml文件
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:conf/spring-*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
配置spring配置文件
spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<!-- 配置handlermapping -->
<mvc:annotation-driven/>
<!-- 启动扫描controller -->
<context:component-scan base-package="com.tedu.cloudnote"/>
</beans>
spring-mybatis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<!-- 配置dbcp组件DataSource -->
<bean id="dbcp" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="root"></property>
<property name="password" value="root"></property>
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/cloud_note">
</property>
</bean>
<bean id="ssf" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dbcp">
</property>
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
<!-- 定义MapperScannerConfigurer -->
<bean id="mapperScanner"
class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.tedu.cloudnote.dao"></property>
<!-- 可以省略不写 -->
<property name="sqlSessionFactory" ref="ssf"></property>
</bean>
</beans>
划分包结构
- com.tedu.cloudnote.controller
- com.tedu.cloudnote.controller.user
- com.tedu.cloudnote.controller.book
- com.tedu.cloudnote.controller.note
- com.tedu.cloudnote.service
- com.tedu.cloudnote.dao
- com.tedu.cloudnote.entity
- com.tedu.cloudnote.util
到这里项目的环境就算搭建好了。下一节开始写项目。
java版云笔记(一)的更多相关文章
- java版云笔记(九)之动态sql
SQL 首先,所谓SQL的动态和静态,是指SQL语句在何时被编译和执行,二者都是用在SQL嵌入式编程中的,这里所说的嵌入式是指将SQL语句嵌入在高级语言中,而不是针对于单片机的那种嵌入式编程. 静态S ...
- java版云笔记(二)
云笔记 基本的环境搭建好了,今天做些什么呢,第一是链接数据库(即搭建Spring-Batistas环境),第二是登录预注册. 注:这个项目的sql文件,需求文档,需要的html文件,jar包都可以去下 ...
- java版云笔记(八)之关联映射
Mybatis关联映射 通过数据库对象之间的关联关系,反映到到实体对象之间的引用. 加载多个表中的关联数据,封装到我们的实体对象中. 当业务对数据库进行关联查询. 关联 <association ...
- java版云笔记(七)之事务管理
事务管理 事务:程序为了保证业务处理的完整性,执行的一条或多条SQL语句. 事务管理:对事务中的SQL语句进行提交或者回滚. 事物管理对于企业应用来说是至关重要的,好使出现异常情况,它也可以保证数据的 ...
- java版云笔记(六)之AOP
今天主要是利用aop技术追加service的响应时间的计算和异常的日志记录. AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object O ...
- java版云笔记(五)
下来是创建笔记本,创建笔记,这个没什么难点和前面是一样的. 创建笔记本 首先点击"+"弹出添加笔记的对话框,然后点击确定按钮创建笔记本. //点击"+"弹出添加 ...
- java版云笔记(四)
页面的笔记本加载完成了,接下来就是点击笔记本显示将笔记显示,同时把笔记在右边的编辑器中,同时把编辑后的笔记更新. 注:这个项目的sql文件,需求文档,需要的html文件,jar包都可以去下载,下载地址 ...
- java版云笔记(三)
登录与注册写好了下来就是主页,今天写的是主页加载时笔记本列表的显示,ajax是固定的就不重点说了.主要说一下jQuery.data() 函数和jQuery.on() 函数. 注:这个项目的sql文件, ...
- ArcGIS Server 10 Java 版的Rest服务手动配置方法
Java版的Manager中发布的服务默认只发布了该服务的SOAP接口,而REST接口需要用户在信息服务器,如Tomcat. Apache.WebLogic等中手工配置.由于在Java版的Server ...
随机推荐
- Seek the Name, Seek the Fame POJ - 2752(拓展kmp || kmp)
题意: 就是求前缀和后缀相同的那个子串的长度 然后从小到大输出 解析: emm...网上都用kmp...我..用拓展kmp做的 这就是拓展kmp板题嘛... 求出extend数组后 把exten ...
- NHibernate 设置主键不自增长
1.Model 配置 [PrimaryKey(PrimaryKeyType.Assigned,"ID")] 2.使用时要手动赋值
- 【纪念】NOIP2018后记——也许是一个新的起点
如果你为了失去太阳而哭泣,那么你也将失去星星和月亮. —— 泰戈尔<飞鸟集> NOIP结束了,我挂了一道题……曾经在心中觉得怎么都不会考到的分数,就这么冷冷的出现在了我的成绩单上.的确是比 ...
- SCWS中文分词,demo演示
上文已经讲了关于SCSW中文分词的安装配置,本节进入demo演示: <?php header('Content-Type:text/html;charset=UTF-8'); echo '< ...
- 《Linux内核设计与实现》第5章读书笔记
第五章 系统调用 一.系统调用概述 系统调用在Linux中称为syscall,返回的值是long型变量:如果出错,C库会将错误代码写入errno全局变量(通过调用perror()函数可以把该变量翻译成 ...
- [知识点]C++中STL容器之map
UPDATE(20190416):写完vector和set之后,发现不少内容全部引导到map上了……于是进行了一定的描述补充与更正. 零.STL目录 1.容器之map 2.容器之vector 3.容器 ...
- 驱动之SPI,UART,I2C的介绍与应用20170118
这篇文章主要介绍基本的驱动也是用的最多的协议类驱动中的SPI,I2C和UART.首先从最简单的UART也就是串口讲起: 1.UART UART由两根线也就是TX,RX以及波特率产生器组成,操作比较简单 ...
- poj2549 Sumsets
Sumsets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11886 Accepted: 3273 Descript ...
- 2018-2019 ACM-ICPC 徐州区域赛 部分题解
题目链接:2018-2019 ACM-ICPC, Asia Xuzhou Regional Contest A. Rikka with Minimum Spanning Trees 题意: 给出一个随 ...
- Linux I/O缓冲
1:两类I/O函数的缓冲机制 1.1 系统调用(System call) 这类代表就是read/write等系统函数,它们是不带缓冲的,这里的缓冲指的是进程缓冲,在内核到磁盘之间还是有内核缓冲的. 1 ...