986244073 / yancy-springboot-jsp

SpringBoot的jspDemo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maven 导入POM依赖

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
</dependency>

配置文件

spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp

编写页面

在main/webapp/WEB-INF/jsp下 写welcome.jsp

<!DOCTYPE html>
<html lang="en">
<body>
Time:  ${time}
<br>
Message: ${message}
</body>
</html>

写WelcomeController.java

@Controller
public class WelcomeController {

    @GetMapping("/")
    public String welcome(Map<String,Object> model){
        model.put("time",new Date());
        model.put("message","hello world!");
        return "welcome";
    }
}
ezoic increase your site revenue

About

SpringBoot的jspDemo


Languages

Language:Java 100.0%