我使用Eclipse WTP Tomcat创建了一个名为“test”的Dynamic Web Projects,Eclipse版本是Java EE Kepler Service Release 2,Tomcat版本是7.0.53,Servlet 3.0,Win 8.1 x86,jdk 1.6.0_45,但之后几次尝试,我发现在匹配以下所有条件时会出现问题:
以下是< CATALINA_HOME> \ conf \ server.xml:
的一部分 <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
<Context docBase="D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test" path="/test" reloadable="true"/>
</Host>
以下是“test”的目录结构:
test
├─META-INF
│ MANIFEST.MF
│
└─WEB-INF
│ web.xml
│
├─classes
│ └─test
│ HelloServlet.class
│ MyFilter1.class
│ MyFilter2.class
│ MyHttpSessionListener.class
│ MyServletContextListener.class
│
└─lib
虽然WEB-INF / web.xml是&lt; WatchedResource&gt;在&lt; CATALINA_HOME&gt; \ conf \ context.xml中默认情况下,我尝试添加&lt; WatchedResource&gt;以下每种格式的元素仍然不起作用:
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF\web.xml</WatchedResource>
<WatchedResource>D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test/WEB-INF/web.xml</WatchedResource>
<WatchedResource>D:\tmpdev\apache-tomcat-7.0.53\wtpwebapps\test\WEB-INF\web.xml</WatchedResource>
HERE是其他有效的配置方式:
答案 0 :(得分:3)
<WatchedResoucre>
仅适用于从server.xml部署上下文时未使用的自动部署功能。
答案 1 :(得分:-2)
重新加载仅在我更新server.xml文件后才起作用!!!
通过设置autoDeploy = true
<br>
The output from the logs then showed a "Reloading context"
08-May-2018 20:58:56.654 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.reload <b>Reloading context </b>[/prototype_maven]
08-May-2018 20:58:56.654 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/prototype_maven] has started
08-May-2018 20:58:58.619 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
08-May-2018 20:58:58.629 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/prototype_maven] is completed