Tomcat的配置(1)

类别:Java 点击:0 评论:0 推荐:

增加一个虚拟目录 在server.xml文件中增加

<Context path="/oicq" docBase="myweb" debug="0" reloadable="true">
</Context>
myweb说明其相对webapps的位置,是物理存在的目录; /oicq说明其相对web URL的路径,是一个虚拟的路径,如:http://localhost/oicq

配置JSP及Servlet


JSP文件直接放在myweb下; 编译好的JavaBean、Servlet放在WEB-INF下的classes目录,而且包的路径要与目录路径一致。

配置服务器的端口

在server.xml文件的第56行,修改port = “8080” 为你所希望使用的端口号,如:80

web.xml文件的设置

默认(欢迎)文件的设置
在h:\tomcat4\conf\web.xml中,
<welcome-file-list>与IIS中的默认文件意思相同。 
<welcome-file-list>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

报错文件的设置

<error-page>
     <error-code>404</error-code>
     <location>/notFileFound.jsp</location> 
</error-page>
<error-page>
     <exception-type>java.lang.NullPointerException</exception-type>
     <location>/null.jsp</location>
</error-page>

如果某文件资源没有找到,服务器要报404错误,按上述配置则会调用H:\tomcat\webapps\ROOT\notFileFound.jsp。
如果执行的某个JSP文件产生 NullPointException ,则会调用H:\tomcat4\webapps\ROOT\null.jsp

本文地址:http://com.8s8s.com/it/it15748.htm