简体   繁体   English

tomcat:部署一个可通过浏览器访问且没有上下文根名称的webapp

[英]tomcat: deploying a webapp which is accessed via browser without context root name

(Sorry for my english, please correct if somethings are wrong). (对不起,我的英语,如果有问题请改正)。

I have a webapp (spring mvc 4 application) which code is placed in tomcat-7/webapp/mywebapp/ folder. 我有一个webapp(spring mvc 4应用程序),其代码位于tomcat-7/webapp/mywebapp/文件夹中。 Webapp is accessed via browser with url http://my-web-app.loc:8080 (ie without context root name mywebapp after port number). 通过浏览器使用URL http://my-web-app.loc:8080访问Webapp(即,在端口号后没有上下文根名称mywebapp )。 I have following setups in tomcat-7/conf/server.xml : 我在tomcat-7/conf/server.xml有以下设置:

<Host name="my-web-app.loc" appBase="webapps" unpackWARs="true" autoDeploy="true">
  <Context path="" docBase="mywebapp" reloadable="true" allowLinking="true" antiJARLocking="true" copyXML="true" />
     <Valve className="org.apache.catalina.valves.AccessLogValve" 
           directory="logs" 
           prefix="mywebapp.access." 
           suffix=".log" 
           pattern="common" 
           resolveHosts="true" />
</Host>

I delploy webapp by placing war-file into /webapp folder. 我通过将war-file放入/webapp文件夹来部署webapp。 But after war-file is unpacked and webapp is successfully deployed, I can access to webapp only with http://my-web-app.loc:8080/mywebapp url. 但是,在打开war文件并成功部署了webapp之后,我只能使用http://my-web-app.loc:8080/mywebapp url访问webapp。 Url http://my-web-app.loc:8080 directs me to 404 tomcat error page. 网址http://my-web-app.loc:8080将我定向到404 tomcat错误页面。

What I have to setup to access to webapp with http://my-web-app.loc:8080 url? 我必须设置什么才能使用http://my-web-app.loc:8080网址访问webapp?

Re-name the directory from mywebapp to ROOT (case matters, even on a case-insensitive filesystem). 将目录从mywebapp重命名为ROOT (大小写无关,即使在不区分大小写的文件系统上也是如此)。

Also, don't put your <Context> element in server.xml . 另外,不要将<Context>元素放在server.xml Instead, put it into your web application under META-INF/context.xml . 而是将其放在META-INF/context.xml下的Web应用程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM