如何将从免费在线源生成的Sitemap.xml和Robot.txt文件集成到Spring Boot Application

时间:2019-05-21 14:35:27

标签: spring-boot seo sitemap

“我有从免费的在线资源生成的 Sitemap.xml Robot.txt 文件,并且我希望将其与Spring Boot应用程序集成”并希望访问 http://localhost:8080/Sitemap.xml

以前,我使用Struts2.x。我通常将这些文件放在JSPs文件夹中,并且可以通过 http://localhost:8080/Sitemap.xml 进行访问。

但是在Spring Boot Application中,我对将它们添加到Application中完全感到困惑。 (我的疑问在下面列出)。

  1. 我需要在哪个文件夹中添加这些文件?

2。是否需要任何控制器以 http://localhost:8080/Sitemap.xml 的身份访问Sitemap.xml。

帮我解决这个问题。

预先感谢。

在静态文件夹下添加了 Sitemap.xml Robot.txt ,但没有使用。

1 个答案:

答案 0 :(得分:0)

您可以将这些文件添加到src / main / resources中的公共文件夹下。 有关更多信息,请参见this

此外,如果您具有安全性配置,则需要进行如下修改:

@Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/Sitemap.xml");
    }