如何绕过 apache tomcat 服务器 url 中的根文件夹名称?
How to bypass root folder name in apache tomcat server url?
我想访问 url 而不必提及 spring MVC 项目中的根文件夹的名称。
示例:
http://localhost:8080/hospitalManagement/user-->http://localhost:8080/user
我需要在 web.xml 文件中进行任何修改吗?
我不确定,但我认为这些步骤可以帮助你
- 在项目的属性中,选择 "Web Project Settings"。
- 将 "Context root" 更改为 "user"。
- 选择 Window > 显示视图 > 服务器。
- 通过单击红色方框(“停止
服务器”工具提示)或上下文单击服务器列表以选择
"Stop".
- 在您要使用的服务器上,右键单击以选择 "Clean…"。
- 在确认对话框中单击“确定”。
现在您可以 运行 使用新的 "user" URL 您的应用,例如:
终于找到答案了...
在请求映射中将值设为 ("/")
@RequestMapping("/")
public String indexController(){
logger.info("IndexController Method called");
return "index";
}
并且也在 web.xml 文件中
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
问题已解决!
我想访问 url 而不必提及 spring MVC 项目中的根文件夹的名称。
示例: http://localhost:8080/hospitalManagement/user-->http://localhost:8080/user
我需要在 web.xml 文件中进行任何修改吗?
我不确定,但我认为这些步骤可以帮助你
- 在项目的属性中,选择 "Web Project Settings"。
- 将 "Context root" 更改为 "user"。
- 选择 Window > 显示视图 > 服务器。
- 通过单击红色方框(“停止 服务器”工具提示)或上下文单击服务器列表以选择 "Stop".
- 在您要使用的服务器上,右键单击以选择 "Clean…"。
- 在确认对话框中单击“确定”。
现在您可以 运行 使用新的 "user" URL 您的应用,例如:
终于找到答案了...
在请求映射中将值设为 ("/")
@RequestMapping("/")
public String indexController(){
logger.info("IndexController Method called");
return "index";
}
并且也在 web.xml 文件中
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
问题已解决!