Tomcat web.xml 和server.xml的配置说明 简单

来源:互联网 发布:多盈软件骗局 编辑:程序博客网 时间:2024/05/27 14:13
Tomcat-->conf-->server.xml的配置说明
   

1、更改端口

 <Connector port="80" protocol="HTTP/1.1"

               connectionTimeout="20000"
               redirectPort="8443" />
  用于配置访问端口一般开发时port=8080 这样在浏览器中调试访问时就要输入
   localhost:8080/hell/**一访问了。
  而如果直接改成80.就可以直接输入localhost/hello/**来访问了。因为浏览器的默认端口是80.注意,可能IIS也会占用80端口。若占用了可以给删除。
  一般开发时,还是用8080不用改了。

2、配置虚拟路径

<Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true">
         <Context path="/js" docBase="E:\eclipse\java_web\jspPrime\WebContent" reloadable="true"/>
<Context path="/word" docBase="D:\apache-tomcat-7.0.35\webapps\hello"/>


<Context>用于配置一个虚拟路径,这样我们开发项目就不用都拷到webapps下了,而是指定一个虚拟路径,这个虚拟路径的名字是path="**" 而实际绝对路径是 docBase所指的。


   注意,server.xml中最好不要出现中文注释,也不把属性名子写错,这样tomcat是启动不了的。




Tomcat-->conf-->web.xml的配置说明




1、是否列出目录

在tomcat中可以访问目录下的文件,列出目录,把listings参数设置成true即可,如下:

<servlet>
...
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
...
</servlet> 


2、默认主页
   <welcome-file-list>  可以再下面添加自己想要到默认主页了
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
<welcome-file>hello.jsp</welcome-file>
    </welcome-file-list>
原创粉丝点击