package com.wyf.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.wyf.model.User;
import com.wyf.service.impl.UserOperationsServiceImpl;
@Controller
@RequestMapping(value = "/redis")
public class UserController {
@Autowired
private UserOperationsServiceImpl userOperationsService;
private User user;
@RequestMapping(value = "/addUser", method = RequestMethod.POST)
public ModelAndView addUser(
@RequestParam(value = "Id", required = true) String Id,
@RequestParam(value = "name", required = true) String name,
@RequestParam(value = "password", required = true) String password) {
user = new User(Id, name, password);
userOperationsService.add(user);
List<User> lists=userOperationsService.getUsers();
Map<String, Object>mapList=new HashMap<String, Object>();
mapList.put("userList", lists);
return new ModelAndView("/WEB-INF/jsp/userList.jsp","user",mapList);
}
@RequestMapping(value = "/addUser", method = RequestMethod.GET)
public String addUser() {
return "/WEB-INF/jsp/AddUser.jsp";
}
@RequestMapping(value = "/queryUser")
public String queryUser() {
return "/WEB-INF/jsp/getUser.jsp";
}
@RequestMapping(value = "/getUser", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getUser(
@RequestParam(value = "key", required = true) String key,Model model) {
user = userOperationsService.getUser(key);
Map<String, Object> maps=new HashMap<String, Object>();
maps.put("uid", user.getId());
maps.put("uname", user.getName());
maps.put("upwd", user.getPassword());
return maps;
}
@RequestMapping(value = "/getUsers")
public ModelAndView getUsers() {
List<User> lists=userOperationsService.getUsers();
Map<String, Object>mapList=new HashMap<String, Object>();
mapList.put("userList", lists);
return new ModelAndView("/WEB-INF/jsp/userList.jsp","user",mapList);
}
@RequestMapping(value = "/updateUser", method = RequestMethod.POST)
public ModelAndView updateUser(
@RequestParam(value = "Id", required = true) String Id,
@RequestParam(value = "name", required = true) String name,
@RequestParam(value = "password", required = true) String password) {
user = new User(Id, name, password);
userOperationsService.add(user);
List<User> lists=userOperationsService.getUsers();
Map<String, Object>mapList=new HashMap<String, Object>();
mapList.put("userList", lists);
return new ModelAndView("/WEB-INF/jsp/userList.jsp","user",mapList);
}
@RequestMapping(value = "/delUser",method = RequestMethod.GET)
public ModelAndView delUser(
@RequestParam(value = "uid", required = true) String uid) {
userOperationsService.deldate(uid);
List<User> lists=userOperationsService.getUsers();
Map<String, Object>mapList=new HashMap<String, Object>();
mapList.put("userList", lists);
return new ModelAndView("/WEB-INF/jsp/userList.jsp","user",mapList);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
在springMVC中java操作redis的封装的增删改查demo
共53个文件
xml:11个
class:7个
java:7个
需积分: 10 11 下载量 128 浏览量
2018-11-07
15:11:03
上传
评论
收藏 1.31MB RAR 举报
温馨提示
在springMVC中java操作redis的封装的增删改查demo --------------
资源推荐
资源详情
资源评论
收起资源包目录
ssm_redisServer.rar (53个子文件)
ssm_redisServer
ssm_redisServer
.project 2KB
.mymetadata 308B
src
test
java
com
wyf
test
Test.java 144B
RedisTest.java 889B
main
webapp
WEB-INF
jsp
getUser.jsp 986B
showUser.jsp 1KB
userList.jsp 4KB
classes
lib
jackson-mapper-asl-1.9.13.jar 762KB
jstl-1.2.jar 405KB
jackson-core-asl-1.9.13.jar 227KB
config
spring-context.xml 1KB
redis-context.xml 2KB
web.xml 2KB
property
redis.properties 139B
index.jsp 916B
js
jquery-1.10.2.js 267KB
AddUser.jsp 1KB
META-INF
MANIFEST.MF 36B
resources
config
spring-context.xml 2KB
redis-context.xml 2KB
property
redis.properties 139B
java
com
wyf
service
UserOperationsService.java 235B
impl
UserOperationsServiceImpl.java 2KB
UserService.java 913B
model
User.java 1KB
controller
UserController.java 3KB
target
m2e-wtp
web-resources
META-INF
MANIFEST.MF 109B
maven
redisServer
redisServer
pom.properties 227B
pom.xml 4KB
m2e-jee
web-resources
META-INF
MANIFEST.MF 104B
maven
redisServer
redisServer
pom.properties 211B
pom.xml 4KB
classes
com
wyf
service
UserService.class 2KB
impl
UserOperationsServiceImpl.class 3KB
UserOperationsService.class 385B
model
User.class 2KB
controller
UserController.class 4KB
test
RedisTest.class 2KB
Test.class 494B
config
spring-context.xml 2KB
redis-context.xml 2KB
property
redis.properties 139B
test-classes
.myeclipse
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 430B
org.eclipse.wst.jsdt.ui.superType.name 6B
com.genuitec.eclipse.j2eedt.core.prefs 56B
org.eclipse.core.resources.prefs 62B
org.eclipse.wst.common.component 664B
.jsdtscope 508B
pom.xml 4KB
.classpath 780B
共 53 条
- 1
资源评论
juone929
- 粉丝: 8
- 资源: 73
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- whl@pip install pyaudio ERROR: Failed building wheel for pyaudio
- Constantsfd密钥和权限集合.kt
- 基于Java的财务报销管理系统后端开发源码
- 基于Python核心技术的cola项目设计源码介绍
- 基于Python及多语言集成的TSDT软件过程改进设计源码
- 基于Java语言的歌唱比赛评分系统设计源码
- 基于JavaEE技术的课程项目答辩源码设计——杨晔萌、李知林、岳圣杰、张俊范小组作品
- 基于Java原生安卓开发的蔚蓝档案娱乐应用设计源码
- 基于Java、Vue、JavaScript、CSS、HTML的毕设设计源码
- 基于Java和HTML的CMS看点咨询系统设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功