In the function of the controller in SPRINGMVC, if you need to get the data from the *.jsp page, you can write it yourself in the function brackets, SPRINGMVC will automatically encapsulate the pass-through.
Spring-mvc.xml
<!--automatically scan --base-package="Cn.itcast.springmvc.service, Cn.itcast.springmvc.web.controller"/> <!--notes Driver- <mvc:annotation-driven/ >
Controller.java two forms are possible, but the second, the parameters in the JSP page are PersonList1
//List@RequestMapping ("/listall") PublicString Listall (map<string,object>model) {List<Person> personlist =Ps.listall (); Model.put ("personlist", personlist); System. out. println ("Listall Hello"); return "person/jpersonlist"; } //List@RequestMapping ("/listallother") PublicString Listallother (model model) {List<Person> PersonList1 =Ps.listall (); Model.addattribute (PERSONLIST1); System. out. println ("Listallother1 Hello"); return "person/jpersonlist"; }
In the JSP page
<%@ page language="Java"pageencoding="UTF-8"%><%@ taglib uri="Http://java.sun.com/jsp/jstl/core"prefix="C"%>'index.jsp'Starting page</title> "padding:10px;"><a href="${pagecontext.request.contextpath}/person/tocreate.action"> New </a></div> <table border="1"><tr> <td>photo</td> <td>id</td> <td>name</td> <td>age</ Td> <td> Operation </td></tr><c:foreach items="${personlist}" var="P"><tr> <td>"${pagecontext.request.contextpath}"/></td> <td>${p.id}</td> <td>${p.name}</td> <td>${p.age}</td> < ;td> <a href="${pagecontext.request.contextpath}/person/toupdate.action?id=${p.id}"> Modifications </a> <a href="${pagecontext.request.contextpath}/person/delete.action?delid=${p.id}"> Delete </a> </td></tr></c:forEach></table> </body>Controller and JSP transfer value in SPRINGMVC