如何始终返回index.html TomCat [英] How to always return index.html TomCat

查看:120
本文介绍了如何始终返回index.html TomCat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在TomCat上实时运行的角度应用程序,但是由于我已经实现了路由,所以如果我手动访问一个URL,则找不到404。同样,当发生错误时,它是一个基本的服务器页面,而不是我的错误URL页面。

I have an angular application running live on TomCat, but since I have implemented routing, if I visit a url manually I get a 404 not found. Also when an error occurs, it's a basic server page, not my error url page.

如何配置TomCat在路由和错误时始终返回index.html?我知道该设置,因为我已经在另一台服务器上完成了设置,所以我只是TomCat的新手,无法在网上找到任何东西。

How do I configure TomCat to always return index.html on routing and on errors? I know the set up, as I have done it with a different server, I'm just new to TomCat and couldn't find anything online.

这是其他后端语言中非常简单的几行代码,我只是在TomCat上找不到任何信息。

From my understanding, it's a pretty straightforward few lines of code in other back-end languages, I just can't find any info on TomCat.

推荐答案

基本上,您必须在tomcat目录的conf文件夹中更改web.xml文件。
$ CATALINA_HOME / conf / web.xml

Basically you have to change web.xml file inside conf folder of tomcat directory. $CATALINA_HOME/conf/web.xml

<error-page> 
    <error-code>404</error-code>
    <location>/error/index.html</location>
</error-page>

并添加一个具有该页面的Web应用程序,并将在给定位置下回答URL。

And add a webapp that has the page and will answer to the URL under given location.

这篇关于如何始终返回index.html TomCat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆