5.创建Contoller类
package com.liuYongQi.SSM.controller; import com.alibaba.fastjson.JSON; import com.liuYongQi.SSM.pojo.Users; import com.liuYongQi.SSM.redis.RedisCache; import com.liuYongQi.SSM.service.UsersService; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import javax.annotation.Resource; import java.util.List; import java.util.Map; /** * @ClassName: UsersController * @Description: TODO 用户处理类 * @Author: Administrator * @CreateDate: 2018/10/19 23:17 * @UpdateUser: Administrator * @UpdateDate: 2018/10/19 23:17 * @UpdateRemark: 修改内容 * @Version: 1.0 */ @Controller public class UsersController { private static Logger logger= LogManager.getLogger(UsersController.class); @Resource private UsersService usersService; @Resource private RedisCache redisCache; /** * @Author Administrator * @Description //TODO redis缓存 * @Date 20:29 2018/10/23 * @Param [map] * @return java.lang.String * @exception */ @RequestMapping("/getAllUsers") public String getAllUsers(Map map){ List<Users> usersList=null; //先从redis中获取 String key="com.liuYongQi.SSM.dao.UsersDao.selectAllUsers"; String data = redisCache.getDataFromRedis(key); if(data==null){ //没有就查询数据库 usersList= usersService.selectAllUsers(); //先把集合对象转换成json String string = JSON.toJSONString(usersList); //把查询的结果放入到redis中 redisCache.setDataToRedis(key,string); }else{ //将data转换成对象集合 usersList=JSON.parseArray(data,Users.class); } map.put("usersList",usersList); return "success"; } }6.创建jsp
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2018/10/19 Time: 23:16 To change this template use File | Settings | File Templates. --%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <a href="/getAllUsers.do">测试redis</a> </body> </html>
OK,下面看一下public区域下所有已打开的端口,命令如下:
firewall-cmd --zone=public --list-ports开端口的地址:https://blog.csdn.net/wlwlwlwl015/article/details/51210347
今天的测试就到这里了,谢谢大家的支持!
如果大家想浏览我的下一篇文章,请留言
版权声明:此文章属于原创,不准随意转载:https://blog.csdn.net/LYQ2332826438