tomcat路径

1         测试文件

index.shtml

<!DOCTYPE html>

<html>

  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <title>index.html</title>

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />

    <meta http-equiv="description" content="this is my page" />

 

  </head>

 

  <body>

    This is my HTML page. <br>

    包含页面<br />

    <h1 style="color:red">相对路径</h1>

    <!--#include virtual="content.html"-->

    <h1 style="color:red">绝对根路径</h1>

    <!--#include virtual="/content.html"-->

    <h1 style="color:red">绝对项目路径</h1>

    <!--#include virtual="/ssi/content.html"-->

  </body>

</html>

 

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <title>My JSP 'index.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">

    <meta http-equiv="cache-control" content="no-cache">

    <meta http-equiv="expires" content="0">

  </head>

 

  <body>

    <h1 style="color:red">相对路径</h1>

    <jsp:include page="content.html"></jsp:include>

    <h1 style="color:red">绝对根路径</h1>

    <jsp:include page="/content.html"></jsp:include>

    <h1 style="color:red">绝对项目路径</h1>

    <jsp:include page="/ssi/content.html"></jsp:include>

    <hr />

    <h1 style="color:red">相对路径</h1>

    <%@ include file="content.html"%>

    <h1 style="color:red">绝对根路径</h1>

    <%@ include file="/content.html"%>

    <h1 style="color:red">绝对项目路径</h1>

    <hr/>

    <a href="content.html"></a>

  </body>

</html>

 

 

content.html

<h1>被包含页面content.html</h1>

2         路径测试

2.1 项目路径webapps/ssi,无特殊配置

可以在地址栏访问:/ssi/content.html

 

 

<!--#include virtual=”-->

<jsp:include page=”” />

<%@ include file=”” %>

相对路径 content.html

正常

正常

正常

根路径 /content.html

报错

正常

正常

项目路径/ssi/content.html

正常

报错

报错

 

2.2 项目路径webapps/ssi,配置context

<Context path="" docBase="D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/ssi"  reloadable="true" ></Context>

可以在地址栏访问:/ssi/content.html

 

 

<!--#include virtual=”-->

<jsp:include page=”” />

<%@ include file=”” %>

相对路径 content.html

正常

正常

正常

根路径 /content.html

正常

正常

正常

项目路径/ssi/content.html

报错

报错

报错

 

2.3 项目路径webapps/ssi,配置host和context

           <Host name="127.0.0.1"  appBase="newapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

                            <Context path="" docBase="D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/ssi"  reloadable="true" ></Context>

           </Host>

不可以在地址栏访问:/ssi/content.html

 

 

<!--#include virtual=”-->

<jsp:include page=”” />

<%@ include file=”” %>

相对路径 content.html

正常

正常

正常

根路径 /content.html

正常

正常

正常

项目路径/ssi/content.html

报错

报错

报错

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值