[英]How to remove whole context from the URL in tomcat 8
I want to remove the whole context from the url. 我想从网址中删除整个上下文。
I have already tried the ROOT.war method for removing the war 我已经尝试过ROOT.war方法来消除战争
Let's say my url is --- https://stackoverflow.com/questions/ask 假设我的网址是--- https://stackoverflow.com/questions/ask
After applying the ROOT.war method i am still getting this-- https://stackoverflow.com/ask 应用ROOT.war方法后我仍然得到this-- https://stackoverflow.com/ask
I want my url like this --- https://stackoverflow.com 我想要这样的网址--- https://stackoverflow.com
How can i achieve this in Tomcat 8 version 我如何在Tomcat 8版本中实现
You are right. 你是对的。 You can remove context-root when you rename your *.war file to ROOT.war.
将* .war文件重命名为ROOT.war时,可以删除context-root。 What you are talking about is to remove "/ask" from url.
您正在谈论的是从URL中删除“ / ask”。 It has nothing common with tomcat.
它与tomcat没有什么共同之处。 In your project you have to set your request to "/" and not to "/ask" .
在您的项目中,您必须将请求设置为“ /”而不是“ / ask”。 In spring-boot you can set with annotation
@GetMapping("/ask") public Greeting sayHello ()
and it means that when you write in browser https://stackoverflow.com/ask then request go into this method. 在spring-boot中,您可以设置注释
@GetMapping("/ask") public Greeting sayHello ()
,这意味着当您在浏览器https://stackoverflow.com/ask中编写时,请求进入此方法。 But when you want to reach the same result but without "/ask" you can write @GetMapping("/ask")
. 但是,当您想获得相同的结果但不带“ / ask”时,可以编写
@GetMapping("/ask")
。 Depends on which framework you are using and there you have to setup this options to redirect request to "/" 取决于您使用的框架,在此必须设置此选项以将请求重定向到“ /”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.