Spring MVC Implementation Query

Source: Internet
Author: User

JSP Query page:
<%@ Pagelanguage= "Java"ContentType= "text/html; charset=utf-8"pageencoding= "UTF-8"%><% @taglibprefix= "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><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>List</title></Head><Body> <C:foreachItems= "${userlist}"var= "Um">-----${um.value.username}-----${um.value.password}-----${um.value.position}-----${UM.V Alue.email}<BR/> </C:foreach></Body></HTML>

Entity class: User

 PackageCn.bdqn.pojo; Public classUser {PrivateString UserName; PrivateString password; PrivateString position; PrivateString Email;  PublicUser (String username,string password,string position,string email) {Super();  This. UserName =UserName;  This. Password =password;  This. Position =position;  This. email =email; }             PublicString GetUserName () {returnUserName; }     Public voidsetusername (String userName) { This. UserName =UserName; }     PublicString GetPassword () {returnpassword; }     Public voidSetPassword (String password) { This. Password =password; }     PublicString getPosition () {returnposition; }     Public voidsetposition (String position) { This. Position =position; }     PublicString Getemail () {returnemail; }     Public voidsetemail (String email) { This. email =email; }        }
View Code

Controller:

@Controller @requestmapping ("/USER") Public classUsercontroller {PrivateMap<string, user> userlist=NewHashmap<string, user>(); Add Data PublicUsercontroller () {Userlist.put ("HL",NewUser ("HL", "123456", "department manager", "[email protected]")); Userlist.put ("Zs",NewUser ("Zs", "123456", "Quality manager", "[email protected]")); Userlist.put ("ZW",NewUser ("ZW", "123456", "Development Engineer", "[email protected]")); Userlist.put ("Ly",NewUser ("ly", "123456", "Implementation Consultant", "[email protected]")); } @RequestMapping (Value= "/userlist", method=requestmethod.get) PublicThe String list (model model) {Model.addattribute ("UserList", userlist); return"User/list"; }    }

Spring MVC Implementation Query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.