zoukankan      html  css  js  c++  java
  • 03-01:springboot 整合jsp

    1.修改pom文件,添加坐标

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

    2. 创建Controller

    @Controller
    public class UserController {
        @RequestMapping("/showUser")
        public String showUser(Model model) {
            List<Users> list = new ArrayList<>();
            list.add(new Users(1,"张三",20));
            list.add(new Users(2,"李四",22));
            list.add(new Users(3,"王五",24));
            model.addAttribute("list", list);
            return "userList";
        }

    3.建立jsp

    <%@ 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>SpringBoot 整合JSP</title>
    </head>
    <body>
        <table border="1" align="center" width="50%">
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>Age</th>
            </tr>
            <c:forEach items="${list}" var="user">
                <tr>
                    <td>${user.id }</td>
                    <td>${user.name }</td>
                    <td>${user.age }</td>
                </tr>
            </c:forEach>
        </table>
    </body>
    </html>

     4.修改application.properties配置文件

    #prefix : 是指访问页面的前缀,指定页面存放的文件夹
    spring.mvc.view.prefix=/WEB-INF/jsp/
    # suffix : 是指文件的后缀名,常见的后缀名有html,jsp,php,txt,mp3 
    spring.mvc.view.suffix=.jsp
  • 相关阅读:
    多级菜单 menu
    PHP 在线 编辑 解析
    [转]在PHP语言中使用JSON
    [转]SSIS ADO.NET vs OLEDB
    [转]SSIS高级转换任务—在Package中是用临时表是需要设置RetainSameConnection属性
    [转]SSIS高级转换任务—行计数
    [转]SSIS Recordset Destination
    [转]SSIS: By coding
    [转]SSIS cannot convert between unicode and non-unicode string
    [转]How to handle Failed Rows in a Data Flow
  • 原文地址:https://www.cnblogs.com/wangjianly/p/9825824.html
Copyright © 2011-2022 走看看