一、新建一个Controller

package cn.cfs.springmvc.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import cn.cfs.springmvc.domain.User;

@Service
public class UserService {
    private static Map<Integer, User> map = new HashMap<Integer, User>();
    static {
        User user = null;
        for (int i = 1; i < 11; i++) {
            user = new User();
            user.setId(i);
            user.setUsername("cifeng" + i);
            user.setPassword("88888888");
            map.put(i, user);
        }
    }

    public List<User> list() {
        return new ArrayList<User>(map.values());
    }

}
UserService

相关文章:

  • 2021-10-18
  • 2021-12-19
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-01-31
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-08-16
  • 2022-12-23
  • 2022-02-22
  • 2021-09-24
  • 2022-02-18
相关资源
相似解决方案