在tomcat Web服务器中托管apple-app-association-file [英] Host apple-app-association-file in tomcat web server
问题描述
我们有一个在应用程序中启用通用链接的要求.我们有一个基于Java的Web应用程序(春季)和一个iOS应用程序.为了按照苹果启用通用链接,我们需要创建一个json文件apple-app-association-file并将该文件托管在服务器中. 现在,将Java Web App部署在Windows Server的tomcat中,并将apche 2.4用作Web服务器.请让我知道如何在tomcat或Web服务器中或war文件中(代码内部)托管apple-app-association-file,我们正在使用maven结构. 根据文档,我们需要删除文件扩展名,并且文件应按如下所示进行访问:
We have a requirement of enabling universal link in our application. We have a java based web application(spring) and a iOS app. To enable universal link as per apple we need to create a json file apple-app-association-file and host this file in the server. Now java web app is deployed in tomcat in windows server and apche 2.4 is being used as web server. Please let me know how to host the apple-app-association-file in the tomcat or web server or inside the war file(inside the code), we are using maven structure. according to docs, we need to remove the file extentsion and file should be access as below:
其中xyz.example.com被映射到一个Web应用程序,该应用程序位于tomcat的webapp文件夹中.(localhost:8080/webApp)
where xyz.example.com is mapped to a web app which is there in webapp folder in tomcat.(localhost:8080/webApp)
apple-app-association-file可以通过以下方式访问: https://xyz .example.com/apple-app-association-file
apple-app-association-file to be accessed as: https://xyz.example.com/apple-app-association-file
现在因为扩展名不存在,我该如何托管它.我是否需要进行代码更改并将其视为servle请求.即使我这样做,仅执行访问服务来访问文件也不是一个好主意
now as the extension is not there how can i host it.Do i need to make the code changes and treated it as servle request. Even if i do so it wont be a good idea to execute a servet just to access a file
此外,使用正确的MIME类型提供文件也很重要,对于Universal Links,可以将其用作application/json.如何在Tomcat或Java Web App(Spring)中设置MIME类型
Also, it's also important that the file is served with the correct MIME-type, for Universal Links it can be served as application/json. How to set mime type in tomcat or java web app(spring)
推荐答案
pITer Simonov 的解决方案对我有用!但是我必须添加根路径 内
The Solution from pITer Simonov works for me! But i had to add the root path inside
< servlet-mapping > (in web.xml)
像这样:
< url-pattern >/</url-pattern >
之后,资源处理程序可以正常工作!
After that, the resource handler work fine!
这篇关于在tomcat Web服务器中托管apple-app-association-file的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!