七、向前台传递参数
七、向前台传递参数
https://www.cnblogs.com/sunniest/p/4555801.html
    //pass the parameters to front-end
    @RequestMapping("/show")
    public String showPerson(Map<String,Object> map){
        Person p =new Person();
        map.put("p", p);
        p.setAge(20);
        p.setName("jayjay");
        return "show";
    }
前台可在Request域中取到"p"
//D:\Indigo_workspace2\TrySpringMVC\src\test\SpringMVC\personController.java //http://localhost:8080/TrySpringMVC/person/showPerson //pass the parameters to front-end //前台可在Request域中取到"p" @RequestMapping("/show") public String showPerson(Map<String,Object> map){ Person p =new Person(); map.put("p", p); p.setAge(20); p.setName("jayjay"); return "show"; } //http://localhost:8080/TrySpringMVC/person/show //Person : //jayjay-20
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!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>D:\Indigo_workspace2\TrySpringMVC\WebContent\WEB-INF\jsp\show.jsp</title> </head> <body> Person :<br/> <c:set var="p" value="${requestScope.p}" /> ${p.name }-${p.age }<br/> <br/> </body> </html>

 

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号