Three methods for importing external files on JSP pages

Source: Internet
Author: User

First:

Introduce the include command of JSP into external files

JSP code
  1. <% @ Include file =
    "../Common/head. jsp"
    %>
<%@include file="../common/head.jsp"%>


Purpose: When page elements are loaded, external page elements are loaded together, which may affect the page loading efficiency.

Second:

Struts label Introduction

JSP code
  1. <Div id =
    "Left"
    Class =
    "Book_left"
    >
  2. <! -- Load content in category. jsp -->
  3. <! -- <S: Action name = "Cate"
    Namespace =
    "/Main"
    Executeresult =
    "True"
    > </S: Action> -->
  4. </Div>
<Div id = "Left" class = "book_left"> <! -- Load content in category. jsp --> <! -- <S: Action name = "Cate" namespace = "/main" executeresult = "true"> </S: Action> --> </div>


Purpose: when loading a page, go back and execute the corresponding action and return the corresponding information element.

Third

Asynchronous requests such as Ajax and jquery

JSP code
  1. <SCRIPT type =
    "Text/JavaScript"
    >
  2. $ ("# Left"
    ). Ajaxstart (function (){
  3. $ (This). Text ("loading ...."
    );
  4. });
  5. $ ("# Left"
    ). Load (
    "../Main/Cate. Do"
    );
  6. </SCRIPT>
<SCRIPT type = "text/JavaScript"> $ ("# Left "). ajaxstart (function () {$ (this ). text ("loading .... ") ;}); $ (" # Left "). load (".. /main/Cate. do "); </SCRIPT>


Purpose: Send an asynchronous request. When the page element is loaded, request the corresponding display content. The page and data are separated to implement asynchronous loading.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.