我的呼呼呼

package njitt.software.crm.controller;

import java.util.List;

import javax.servlet.http.HttpSession;
import javax.websocket.Session;

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 njitt.software.crm.bean.UserInfo;
import njitt.software.crm.service.UserInfoService;

@Controller
public class UserInfoController {
    
    @Autowired
    private UserInfoService service;
    

    @RequestMapping("/findUserInfos")
    public String findUserInfos(Model model,HttpSession session){
        List<UserInfo> user = service.findUserInfo();
        model.addAttribute("Session",user);
        session.setAttribute("Session",user);
    
        
        return "index";
        
    }

}

package njitt.software.crm.mapper;

import java.util.List;

import njitt.software.crm.bean.UserInfo;

public interface UserInfoMapper {
    
    public List<UserInfo> findUserInfo();

}

package njitt.software.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import njitt.software.crm.bean.UserInfo;
import njitt.software.crm.mapper.UserInfoMapper;
import njitt.software.crm.service.UserInfoService;

@Service
@Transactional
public class UserInfoServiceImpl implements UserInfoService {
    
    @Autowired
     
    private UserInfoMapper user;

    @Override
    public List<UserInfo> findUserInfo() {
        
        return user.findUserInfo();
    
    }

}

package njitt.software.crm.service;

import java.util.List;

import njitt.software.crm.bean.UserInfo;

public interface UserInfoService {
    
    public List<UserInfo> findUserInfo();
}

package njitt.software.crm.test;


import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import njitt.software.crm.bean.UserInfo;
import njitt.software.crm.service.UserInfoService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")
public class UserInfoTest {
    
    @Autowired
    private UserInfoService userInfoService;
    
    
    @Test
    public void findUserInfo() {
        List<UserInfo> list = userInfoService.findUserInfo();
        for(UserInfo userInfo : list) {
            System.out.println(userInfo);
        }
    }

}

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
  <div>
      <table>
           <thead>
               <tr>
                  <td>编号</td>
                  <td>名称</td>
                  <td>cpu</td>
                  <td>内存</td>
               </tr>
           </thead>
           <tbody>
              <c:forEach items="${Session}" var="Session">
                    <tr>
                       <td>${Session.id}</td>
                       <td>${Session.name}</td>
                       <td>${Session.cpu}</td>
                       <td>${Session.memory}</td>
                   
                 </tr>
              </c:forEach>
           </tbody>
      </table>
  
  
  
  </div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ahu123.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值