码迷,mamicode.com
首页 > 编程语言 > 详细

spring mvc实现查询

时间:2015-11-10 12:30:52      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

jsp查询页面:
<
%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>list</title> </head> <body> <c:forEach items="${userlist}" var="um"> -----${um.value.userName} -----${um.value.password} -----${um.value.position} -----${um.value.email} <br/> </c:forEach> </body> </html>

实体类:User

技术分享
package cn.bdqn.pojo;

public class User {
    private String userName;
    private String password;
    private String position;
    private String email;
    
    public User(String userName,String password,String position,String email){
        super();
        this.userName = userName;
        this.password = password;
        this.position = position;
        this.email = email;
    }
    
    
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getPosition() {
        return position;
    }
    public void setPosition(String position) {
        this.position = position;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    
    
}
View Code

控制器:

@Controller
@RequestMapping("/user")
public class UserController {
    private Map<String, User> userList= new HashMap<String, User>();
    //添加数据
    public UserController() {
        userList.put("hl", new User("hl","123456","部门经理","hanlu@bdqn.cn"));
        userList.put("zs", new User("zs","123456","质量经理","zhangsan@bdqn.cn"));
        userList.put("zw", new User("zw","123456","开发工程师","zhangwei@bdqn.cn"));
        userList.put("ly", new User("ly","123456","实施顾问","liyu@bdqn.cn"));
    }
    
    @RequestMapping(value="/userlist",method=RequestMethod.GET)
    public String list(Model model){
        model.addAttribute("userlist",userList);
        return "user/list";
    }
    
}

 

spring mvc实现查询

标签:

原文地址:http://www.cnblogs.com/xuerong/p/4952276.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!