When developing a jsp page, there are a lot of pages that use the same page structure. These same page structures are not only added when each page is added, but also need to be modified if you want to modify these same places, which brings development and maintenance. The amount of work.
Think through the object-oriented problem: If the same part is extracted, use the inherited relationship, and the basic has the parent class definition, the subclass can override the changed content of the parent class. A parent class can have multiple subclasses. A subclass has only one parent class. A subclass can have many subclasses. This multi-level inheritance can solve the above problem.
The same is true for the page. If you extract the same partial page structure into a parent page, you can use the child page to inherit the parent page from the child page. You can override the page content of the page different from the main page, or you can define the own. The subpage of the page is overwritten. When adding, just importing the parent page and modifying the content for yourself will no longer care about the same page structure. When you want to modify the same page structure, as long as you modify the content of the parent page, the descendant pages referenced below will be updated accordingly.
I mainly use it in the jsp page, so I only introduce the jar package that needs to be introduced in jsp: rapid-core-4.0.jar
Maven introduces:
<dependency>
<groupId>com.googlecode.rapid-framework</groupId>
<artifactId>rapid-core</artifactId>
<version>4.0.5</version>
</dependency>
Because this function is mainly used in the jsp page, it is implemented by using the tag library method, so the tag library is first referenced in jsp.
<%@taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid" %>
Parent page: base.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<body>
<rapid:block name="content">
Here is the content
</rapid:block>
</body>
<rapid:block name="content">Define a block called content that can be used to rewrite subpages.
subpage: child.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<rapid:override name="content">
Here is the rewriting content
</rapid:override>
<%@ include file="base.jsp"%>
<%@ include file="base.jsp"%>Introduction to the parent page
<rapid:override name="content">Override the part of the parent page called content.
Access the subpage, the parent page <rapid:block name="content">The internal elements are not displayed, instead of the subpage rewrite.
The system login page is login.jsp. After successful login, go to the main.jsp page. This page is a top-and-bottom frame structure. The upper frame page is top.jsp and exits in top.jsp. Execute a sess...
After Tomcat starts, check the page: I found some information on the Internet and said that it was because static resources were blocked under the ssh framework, but there was no solution, but I found...
This article is mainly to display a course schedule, the main ideas are as follows (using the framework springmvc+spring+mybatis): The course to be displayed is obtained from the database and returned...
Project background: Recently due to project needs, a project with third-party docking, third parties put the report to us in the Base64 encrypted binary code code, directly put this value in the field...
test02.jsp test02.js Test02.jsp and test02.js are currently located as follows: Load test02.jsp in the Firefox browser. Normal conditions should be displayed: But Hello has not been displayed. A...
Note: Because JSP technology itself has many defects, SpringBoot does not support JSP by default, so when integrating JSP, the project needs to pay attention to the war package. Integration steps: 1. ...
There are two ways to display a page: One is a traditional action, which finds data from the action and then passes it to the JSP page for display with JSTL; The second use ajax to get data from the a...
Wrong point:c:setMust be used in the labelvarProperty, I only used itpropertyAttribute, so an error is reported; Solution:willpropertychange intovarYou can The error code is as follows (not much refer...
A recent project, made a report statistical histogram. I feel very good, and record it. Project uses strus1 +spring+ibatis Specific code as follows: the followingJavaCommented code is a bar graph is d...
For safety reasons, the project needs, need jsp page display function watermark to prevent the disclosure of user information. Directly in the project initialization function in the js code below into...