贫民窟里的程序高手

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  871 随笔 :: 5 文章 :: 42 评论 :: 132万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

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>
复制代码

 

posted on   贫民窟里的程序高手  阅读(168)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
历史上的今天:
2011-11-23 jquery validate 笔记
点击右上角即可分享
微信分享提示