【javaWeb第四天】-Web资源访问概述

来源:互联网 发布:完美卸载软件评价 编辑:程序博客网 时间:2024/06/06 04:30

netstat - ano查看端口占用情况


Web应用供外界访问方法
1.放在tomcat的webapp文件夹中。
2.虚拟映像
tomcat提供5种方法。
http://localhost:8080/docs/config/context.html

Context elements may be explicitly defined:

  • In the $CATALINA_BASE/conf/context.xml file: the Context element information will be loaded by all webapps.
  • In the $CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host.
  • In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml extension) will be used as the context path. Multi-level context paths may be defined using #, e.g. foo#bar.xml for a context path of /foo/bar. The default web application may be defined by using a file called ROOT.xml.
  • Only if a context file does not exist for the application in the $CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-INF/context.xml inside the application files. If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to match the application's context path. Once this file exists, it will not be replaced if a new WAR with a newer/META-INF/context.xml is placed in the host's appBase.
  • Inside a Host element in the main conf/server.xml.


使用第四种
若Tomcat 和Web应用不在同一个盘中,可在tomcat的conf/Catalina/localhost目录中加一个XML文件,文件名为虚拟映像名,如zpy.xml,内容为<Context docBase="F:\web文件名"/>,服务器会自动加载该应用。


在项目的Web-inf目录中可配置首页,输入项目名即可访问(http://localhost:8080/Test/)

<welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>





reloadable 设置为true.改过之后 不需要重新发布,服务器会自动 更新。在实际开发中最好不要配制,因为一但改动就会重新加载,应用较大时一旦连续加载会挂掉。