spring-boot - 如何将免费在线源生成的 Sitemap.xml 和 Robot.txt 文件集成到 Spring Boot 应用程序中
问题描述
“我有从免费在线资源生成的Sitemap.xml和Robot.txt文件,我想将它们与我的 Spring Boot 应用程序集成”并希望以http://localhost:8080/Sitemap.xml的形式访问它。
以前我使用 Struts 2.x。我通常将这些文件放在 JSPs 文件夹中,我可以通过http://localhost:8080/Sitemap.xml访问它。
但是在 Spring Boot Application 中,我对将它们添加到 Application 中完全感到困惑。(我的疑问在下面列出)。
- 我需要在哪个文件夹中添加这些文件?
2.是否需要任何控制器以http://localhost:8080/Sitemap.xml 访问 Sitemap.xml。
帮我解决这个问题。
提前致谢。
在静态文件夹下添加了Sitemap.xml和Robot.txt,但没有使用。
解决方案
您可以在 src/main/resources 的 public 文件夹下添加这些文件。有关更多信息,请参阅此。
此外,如果您有安全配置,则需要进行如下修改:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/Sitemap.xml");
}
推荐阅读
- javascript - 如何逐步循环一个数字但不超过javascript中的数字
- cookiecutter-django - 如何增加 cookiecutter-django 的超时时间
- java - Android客户端套接字未连接到python服务器套接字
- dialogflow-es - 我需要为出租车预订应用程序谷歌操作实施谷歌事务 API 吗?因为谷歌操作中没有付款流程
- reactjs - 为什么重新部署应用后 Firebase 需要永远完成相同的功能?
- installation - SQL 安装错误:MOF 编译器无法与 WMI 服务器连接
- amazon-web-services - terraform 模块 ec2 和 vpc AWS
- java - 填充可重用方法 Java 中使用的常量映射的最佳实践
- python - 在python中仅绘制选定的行
- angular - ../node_modules/nativescript-plugin-firebase/firebase.js 中的 Nativescript 错误