【发布时间】:2017-07-15 08:00:49
【问题描述】:
我有一个使用 Spring Boot 和 Jersey 的项目设置,我需要提供静态内容。与其他类似问题的主要区别在于“mywebsite.com/”必须是泽西岛资源。这是我当前的 JerseyConfig:
@ApplicationPath("/")
@Configuration
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
packages("com.mywebsite.services.rest",
"com.mywebsite.services.publication");
property(ServletProperties.FILTER_FORWARD_ON_404, true);
}
}
还有我的出版资源:
@Component
@Path("/")
@Produces(MediaType.TEXT_HTML)
public class PublicacionResource {
@GET
public Template index() throws Throwable {
return generateTemplateWithParameters("instalaciones", null, null);
}
...
}
Jersey 似乎没有转发 404 请求,因为我无法访问静态内容。
【问题讨论】:
-
您是否将 Jersey 配置为作为过滤器运行?
-
是的,我设置了
spring.jersey.type=filter -
“与其他类似问题的主要区别在于“mywebsite.com/”必须是泽西岛资源。” - 这是否意味着没有 @987654324 @资源,它有效吗?
-
或者这是访问 MVC 内容的问题?静态内容和 MVC 内容是不同的故事
-
我的意思是我需要位于根 URL“/”的 Jersey 资源,并且还需要提供静态内容。所以我看到的其他解决方案说在 /rest 处启动
@ApplicationStart作为一种解决方法,但这不是我的选择。
标签: java spring-boot servlet-filters jersey-2.0