我不想把写好的.jsp文件放在D:\Tomcat 5.0\webapps\jsp-examples下怎么办
需要修改server.xml文件:假如你的.jsp文件都放在e:\MyJsp下,则在该文件的<Host></Host>之间加入这样一段代码
那请问<Host></Host>放在XML的哪里呢
需要修改server.xml文件:假如你的.jsp文件都放在e:\MyJsp下,则在该文件的<Host></Host>之间加入这样一段代码
那请问<Host></Host>放在XML的哪里呢
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">; 改成:
<!-- Define the default virtual host -->;
<Host name="localhost" debug="0" appBase="e:\MyJsp"
unpackWARs="true" autoDeploy="true">;
先把注释去掉,然后在 docBase 中设置上你的网站根目录,哪下是我的那一段配置文件,其中的中文是为了说明写注释: <!-- Tomcat Root Context -->
<!-- path 表示在浏览器里的目录,空表示根目录, docBase 表示在硬盘上所在的目录 -->
<Context path="" docBase="h:\wwwroot\tomcat" debug="0"/>
<!-- http://localhost:8080/tomcat_docs 所指向的硬盘目录, 这是是 tomcat 的一些文档 -->
<Context path="/tomcat_docs" docBase="e:\tomcat\webapps\tomcat-docs" debug="0"/>
<!-- Tomcat Manager Context -->
<!-- 下面两项是对原来的进行修改以适应根目录的变化的, 即打开上述注释 -->
<Context path="/manager" docBase="e:\tomcat\webapps\manager"
debug="0" privileged="true"/> <!-- Tomcat Examples Context -->
<Context path="/examples" docBase="e:\tomcat\webapps\examples" debug="0"
reloadable="true" crossContext="true">注意:这时候端口是默认的 8080,需要使用 http://localhost:8080/ 才能访问
要改端口需要找到 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>将端口 port 设置为 80, 改后如下 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
port="80" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="60000"/>
另外我发现在Tomcat 4.1中可以在webapps目录中可以建一文件如:MyJsp.xml<?xml version='1.0' encoding='utf-8'?>
<Context path="/MyJsp" docBase="e:\MyJsp" reloadable="true">
</Context>同样可以。
在server.xml中找到
<host>......
</host>
在</host>上面写如以下代码
<Context path="/myjsp" docBase="绝对路径" dubug="0" reloadable="true" crossContext="true"/>
例如:
<Context path="/myjsp" docBase="E:\myjsp\web\" debug="0" reloadable="true" crossContext="true"/>
重新启动tomcat
在地址栏中输入
http://localhost:8080/myjsp