Controller and JSP transfer value in SPRINGMVC

Source: Internet
Author: User

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.


Join in

1 <!--auto-scan-->2 <context:component-scan base-package= "Cn.itcast.springmvc.service, Cn.itcast.springmvc.web.controller "/>3 <!--note Driver-->4 <mvc:annotation-driven/> two forms are possible, but the second, the parameters in the JSP page are PersonList1

List      @RequestMapping ("/listall")     public string 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")     public  String 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// " prefix=" C "%>El expression notation: ${pagecontext.request.contextpath}

JSP notation: <%=request.getcontextpath ()%>

Controller and JSP transfer value in SPRINGMVC

Related Article

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: 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.