读书人

tomcat途径

发布时间: 2012-09-13 09:51:53 作者: rapoo

tomcat路径
1 测试文件

index.shtml

<!DOCTYPEhtml>

<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"%>

<!DOCTYPEHTML 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>

<%@ includefile="content.html"%>

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

<%@ includefile="/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

报错

报错

报错

读书人网 >编程

热点推荐