Как решить mediaType
не должно быть пустой ошибки в Spring 3.0 MVC? Одним из наших требований мы хотим реализовать «Поддержка универсальных ссылок» для мобильного приложения:
Путь к файлу должен быть: http://localhost:9080/.well-known/apple-app-site-association
Когда я запрашиваю URL https://localhost:9080/.well-known/apple-app-site-association
Мы получаем следующую ошибку:
Ошибка:
[5/7/18 10:54:38:776 EDT] 00000125 SystemOut O 2018-05-07 10:54:38,757 ERROR PageController - Exception while processing request for: /.well-known/apple-app-site-association
java.lang.IllegalArgumentException: 'mediaType' must not be empty
at org.springframework.util.Assert.hasLength(Assert.java:136) ~[spring-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.http.MediaType.parseMediaType(MediaType.java:687) ~[spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at com.sdl.webapp.common.impl.interceptor.StaticContentInterceptor.fallbackForContentProvider(StaticContentInterceptor.java:79) ~[dxa-common-impl-1.5.0.jar:1.5.0]
at com.sdl.webapp.common.impl.interceptor.StaticContentInterceptor.preHandle(StaticContentInterceptor.java:111) ~[dxa-common-impl-1.5.0.jar:1.5.0]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:914) ~[spring-webmvc-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) ~[spring-webmvc-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) ~[spring-webmvc-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) ~[spring-webmvc-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) [javax.j2ee.servlet.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) [javax.j2ee.servlet.jar:na]
Мой контроллер:
package com.sdl.webapp.main.controller;
import com.sdl.webapp.common.api.WebRequestContext;
import com.sdl.webapp.common.api.localization.Localization;
import com.sdl.webapp.common.api.localization.LocalizationResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
@Controller
public class AdminController
{
private static final Logger LOG = LoggerFactory.getLogger(AdminController.class);
private String successView;
@Autowired
private WebRequestContext webRequestContext;
@Autowired
private LocalizationResolver localizationResolver;
public AdminController() {}
@RequestMapping(method=RequestMethod.GET, value="/.well-known/apple-app-site-association", headers="content-type=application/json", produces = "application/json", consumes = "application/json")
public String getHeaders(@RequestHeader(value="Content-Type", required=false, defaultValue="application/json") String ContentType, @RequestHeader(value="Accept", defaultValue="application/json") String accept)
{
Localization localization = webRequestContext.getLocalization();
LOG.trace("ContentType : " + ContentType);
return localization.getPath() + "/.well-known/apple-app-site-association";
}
}