怎么更改Tomcat的URL根映射路径

hh12 2003-04-27 11:59:16
在Tomcat安装路径\conf目录下:配置文件server.xml
输入
<Context path="" docBase="webapps/mysample" debug="0" reloadable="true">
</Context>

不能更改URL根映射路径,,请问各位高手是什么原因,帮帮忙!
...全文
783 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
shaopin 2003-04-28
  • 打赏
  • 举报
回复
Context path="虚拟路径"
docBase="实际路径"

比如:
<Context path="jspfile" docBase="d:\jspfile" debug="0" reloadable="true"/>
访问:
http://localhost:8080/jspfile
hh12 2003-04-28
  • 打赏
  • 举报
回复
<Context path="/jspfile" docBase="jspfile" debug="0" reloadable="true"/>
访问:
http://localhost:8080/jspfile

注:要重新启动Tomcat服务器(调试成功)

多谢各位高手的热心帮忙!!!!!!!
多谢!!!!!!!!
Successful 2003-04-28
  • 打赏
  • 举报
回复
1.根路径设定方法:
在Tomcat配置文件server.xml中添加:
<Context path="" docBase="实际路径(如:D:\home_jsp)" debug="0" reloadable="true" />
访问方式:http://locahost:8080/
-----------------------------------------------------------------------
2.相对路径设定方法:
在Tomcat配置文件server.xml中添加:
<Context path="/文件夹名" docBase="实际路径(如:D:\manager)" debug="0" reloadable="true" />
访问方式:http://locahost:8080/文件夹名

hh12 2003-04-28
  • 打赏
  • 举报
回复
<Host name="localhost" debug="0" appBase="d:/wwwroot"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="d:/wwwroot" debug="0"
reloadable="true" crossContext="true"/>
</Host>

我测试,还是不能成功!!!!
这是什么原因,再帮帮忙!!!!

hh12 2003-04-28
  • 打赏
  • 举报
回复
请各位高手,再援助,援助
多谢!!!
hh12 2003-04-28
  • 打赏
  • 举报
回复
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Service name="Tomcat-Standalone">

<!-- 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"/>

<!-- Note : To disable connection timeouts, set connectionTimeout value
to -1 -->

<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8081 -->

<!-- Define an SSL HTTP/1.1 Connector on port 8443 -->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>

<!-- Define a Proxied HTTP/1.1 Connector on port 8081 -->
<!-- See proxy documentation for more information about using this. -->

<!-- Define a non-SSL HTTP/1.0 Test Connector on port 8082 -->

<!-- Define the top level container in our container hierarchy -->
<Engine name="Standalone" defaultHost="localhost" debug="0">

<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->

<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>

<!-- Because this Realm is here, an instance will be shared globally -->

<Realm className="org.apache.catalina.realm.MemoryRealm" />

<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->

<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">

<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn"
debug="0"/>
-->
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>


<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0"/>
-->

<!-- Tomcat Manager Context -->
<Context path="/manager" docBase="manager"
debug="0" privileged="true"/>
<!-- Tomcat Examples Context -->



<!--是不是在这里输入-->
<!--第一种输入-->
<Context path="jspfile" docBase="d:\jspfile" debug="0" reloadable="true"/>
<!--第二种输入-->
<Context path="/jspfile" docBase="jspfile" debug="0" reloadable="true"/>
<!--两种不同的输入,测试,都不能成功,这是什么原因-->


<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_examples_log." suffix=".txt"
timestamp="true"/>
<Ejb name="ejb/EmplRecord" type="Entity"
home="com.wombat.empl.EmployeeRecordHome"
remote="com.wombat.empl.EmployeeRecord"/>
<Environment name="maxExemptions" type="java.lang.Integer"
value="15"/>
<Parameter name="context.param.name" value="context.param.value"
override="false"/>
<Resource name="jdbc/EmployeeAppDb" auth="SERVLET"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter><name>user</name><value>sa</value></parameter>
<parameter><name>password</name><value></value></parameter>
<parameter><name>driverClassName</name>
<value>org.hsql.jdbcDriver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc:HypersonicSQL:database</value></parameter>
</ResourceParams>
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
</Context>

</Host>

</Engine>

</Service>


<!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">

<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>

<!-- Replace "localhost" with what your Apache "ServerName" is set to -->
<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">

<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>

<!-- Because this Realm is here, an instance will be shared globally -->
<Realm className="org.apache.catalina.realm.MemoryRealm" />

</Engine>

</Service>

</Server>
shfan 2003-04-28
  • 打赏
  • 举报
回复
补充:其实就是修改appBase的目录为d:/wwwroot和修改默认的url根目录为d:/wwwroot
shfan 2003-04-28
  • 打赏
  • 举报
回复
修改server.xml
<Host name="localhost" debug="0" appBase="d:/wwwroot"
unpackWARs="true" autoDeploy="true">
同时:
<Context path="" docBase="d:/wwwroot" debug="0"
reloadable="true" crossContext="true"/>

其中,d:/wwwroot是你的web文件目录。这个是我的修改,以供参考
hh12 2003-04-28
  • 打赏
  • 举报
回复
多谢各位高手帮忙!!

多谢!!!!!!!

up!!!!
njyyao 2003-04-27
  • 打赏
  • 举报
回复
docBase="..."改成你的实际路径就可以了啊
奇伢 2003-04-27
  • 打赏
  • 举报
回复
看这样行不行:<Context path="" docBase="webapps\mysample" debug="0" reloadable="true">
</Context>

Alain_Delone 2003-04-27
  • 打赏
  • 举报
回复
你要改 WEBAPPS目录的地方?
不指向WEBAPPS?
redlittlebear 2003-04-27
  • 打赏
  • 举报
回复
去掉</Context>:)

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧