该项目包含springBoot-example-ui 和 springBoot-example,分别为前端与后端,先后端分离,利用ajax交互。css
springBoot-example-ui
BootStrap
+ layer
+ jquery
+ css
+ html
springBoot-example
注意:涉及跨域,故springBoot-example
在 controller
类上添加类了@CrossOrigin
,以此支持跨域请求html
首页(路径为springBoot-example-ui\index.html)(这里项目名称为zeus-ui,下同) 前端
首页请求分析java
以删除为例:mysql
后端以springboot、maven多模块为基础框架,数据库为mysql+redis,实现简单的CRUD功能。先后端以RESTFUL风格的ajax请求来进行交互。jquery
springBoot-api 控制层,主要是各种controllergit
springBoot-base 接口层,包含service接口和entiy实体类github
springBoot-util 工具类层ajax
项目代码整体结构以下:redis
项目成功启动时,控制台:
@RestController public class RedisExampleController { @Autowired private IRedisService redisService; @RequestMapping("/redis/set") public Object redisSet(@RequestParam("value")String value){ boolean isOk = redisService.setString("name", value); if(isOk){ return new XPFSingleResponse("redis新增成功"); }else{ return new XPFBadRequestException("redis新增失败"); } } @RequestMapping("/redis/get") public Object redisGet(){ String name = redisService.getString("name"); return new XPFSingleResponse("redis获取:" + name); } }
#REDIS # Redis数据库索引(默认为0) spring.redis.database=0 # Redis服务器地址 spring.redis.host=127.0.0.1 # Redis服务器链接端口 spring.redis.port=6379 # Redis服务器链接密码(默认为空) spring.redis.password= # 链接池最大链接数(使用负值表示没有限制) spring.redis.pool.max-active=8 # 链接池最大阻塞等待时间(使用负值表示没有限制) spring.redis.pool.max-wait=-1 # 链接池中的最大空闲链接 spring.redis.pool.max-idle=8 # 链接池中的最小空闲链接 spring.redis.pool.min-idle=0 # 链接超时时间(毫秒) spring.redis.timeout=0