首页 > 解决方案 > 如何将免费在线源生成的 Sitemap.xml 和 Robot.txt 文件集成到 Spring Boot 应用程序中

问题描述

“我有从免费在线资源生成的Sitemap.xmlRobot.txt文件,我想将它们与我的 Spring Boot 应用程序集成”并希望以http://localhost:8080/Sitemap.xml的形式访问它。

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

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

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

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

帮我解决这个问题。

提前致谢。

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

标签: spring-bootseositemap

解决方案


您可以在 src/main/resources 的 public 文件夹下添加这些文件。有关更多信息,请参阅

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

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

推荐阅读