发表于: 2020-06-20 19:37:36

1 1884


Task4

创建学生表

CREATE TABLE `student` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `namevarchar(255) NOT NULL COMMENT '姓名',
  `img` varchar(255) NOT NULL COMMENT '图片',
  `opt` varchar(255) NOT NULL COMMENT '职位',
  `intro` varchar(255) NOT NULL COMMENT '介绍',
    `is_hot` varchar(255) NOT NULL COMMENT '',
  `create_at` bigint(20) NOT NULL COMMENT '创建时间',
  `create_by` bigint(20) NOT NULL COMMENT '创建人',
  `update_at` bigint(20) NOT NULL COMMENT '更新时间',
  `update_by` bigint(20) NOT NULL COMMENT '更新人',
  PRIMARY KEY (`id`)

改动generator.xml逆向工程生成student 和 content表的mappers和pojo和dao

jsp/index.html

本来是t11.html但是为了用传参(contentlist.get(0))变成jsp动态页面

<li class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
   <div>
       <img src="${studentList.get(3).img}" height="300px" width="200px">


腾讯云服务器-对象存储-上传图片-复制对象地址


Tiles框架

Tiles 框架彻底揭示了 jsp:includes 内部的概念 ―― 从而允许您更灵活地创建可重用的页面。使用 Tiles 框架,开发人员能够通过组合可重用的 tile 来构建页面。您应该将 tile 看作是可视组件。

Tile 布局是允许在其上放置其他 tile 的特殊 JSP 页面。 Tile 布局控制了 tile 在页面上的放置位置。从许多方面看来,tile 布局都和模板布局类似。事实上,如果以前使用过 Struts,那么您会注意到 Tile 框架与模板自定义标签库向是后兼容的。

术语

Tiles   Struts 用来创建表示组件的模板框架。
页面    tile 布局包括的 Web 资源。
Tile     同页面。
区域    tile 布局中插入其他 tile 的范围。 区域拥有诸如页眉、页脚之类的逻辑名称。
Tile 布局  描述其他页面应该定位在何处的 JSP 页面。Tile 布局充当模板,定义了插入其他 tile 的区域。 一个 tile 布局可以是另一个 tile 布局的 tile。
定义     定义用于调用某个 tile 布局的参数。

典型的 tile 布局

典型的 tile 布局可能为页眉、页脚、菜单和正文定义矩形区域

Tile 布局

从某些方面看来,tile 布局工作起来就像一个显示函数。要使用某个 tile 布局,可使用 tiles:insert 标签来调用它。调用 tile 布局时要向它传递参数。这些参数将成为该 tile 布局的属性;例如,参数将放入 tile 范围。

调用 tile 时传递的参数可以是其他 JSP 页面或 Web 资源,您可以将它们插入布局中的预定义位置(称为 区域)。参数还包含能够插入 tile 布局的字符串。事实上,可以将许多类型的对象作为参数传递给 tile。这些参数会成为仅对该 tile 可用的 tile 范围内的属性。

tile 范围 类似页面范围,因为 tile 范围比请求范围更特殊化。 tile 范围允许 tile 用户给 tile 传递参数(称为属性)。tile 范围允许您传递仅对该 tile 布局或 tile 可用的变量(称为属性)。 特殊自定义标签允许您将属性从 tile 范围复制到页面、请求、会话或应用程序范围,或者将属性作为包含的 Web 资源来显示。

参考:https://www.cnblogs.com/laoyangHJ/articles/tilesframe1.html

更改路径

command+shift+R replace All

index.html

<html>
<head>
   <jsp:forward page="/WEB-INF/jsp/index.jsp"/>
</head>
<body>
<h2>Hello World! index</h2>
</body>
</html>



tomcat-run报错 Could not open ServletContext resource [/WEB-INF/applicationContext.xml] 且无法展示页面

解答

直接把web.xml里的ContextLoaderListener给comment掉


出现乱码,是index.jsp的头部没写好,更改为

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>



不懂为什么要在webapp目录下放一个和WEB-INF/jsp/job.html一样的job.html才能看到职位页面。WEB-INF/jsp/job.html和WEB-INF/jsp/index.html在intellij里都可以实现成功跳转。但是在浏览器里不行。






返回列表 返回列表
评论

    分享到