ViewController:
package com.keafmd.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; /** * Keafmd * * @ClassName: ViewController * @Description: * @author: 牛哄哄的柯南 * @Date: 2021-04-02 14:47 * @Blog: https://keafmd.blog.csdn.net/ */ @Controller public class ViewController { @GetMapping("getname") public String getName(Model model){ model.addAttribute("name","keafmd"); return "name"; } @GetMapping("getage") public String getAge(Model model){ model.addAttribute("age",18); return "age"; } }
在webapp下创建name.jsp和age.jsp
name.jsp:
<%-- Created by IntelliJ IDEA. User: lenovo Date: 2021/4/2 Time: 14:31 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <h1>name</h1> ${name} </body> </html>
age.jsp:
<%-- Created by IntelliJ IDEA. User: lenovo Date: 2021/4/2 Time: 15:29 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <h1>age</h1> ${age} </body> </html>
标签:传参,springboot,keafmd,ViewController,age,jsp,model,name From: https://www.cnblogs.com/wpcnblog/p/16919649.html