从资源导航到实例

从资源导航到实例

本文介绍了Jersey2:从资源导航到实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试回答以下问题:什么是Jersey 2替代ResourceContext.matchResource(URI)?

I am attempting to answer this question: What is the Jersey 2 replacement for ResourceContext.matchResource(URI)?

我设法从ResourceModel导航到匹配的Resource,但是目前尚不清楚如何实例化相应的用户类.

I've managed to navigate from a ResourceModel to a matching Resource, but it's not clear how to instantiate the corresponding user class.

意思是,因为org.glassfish.jersey.server.model.Resource映射到某些用户定义的类CompaniesResource,如何从Resource中获取CompaniesResource实例?

Meaning, given org.glassfish.jersey.server.model.Resource that maps to some user-defined class CompaniesResource, how do I get a CompaniesResource instance out of the Resource?

棘手的是,这需要使用从URI解析的值来调用子资源定位符.

The tricky part is that this needs to invoke subresource locators with values parsed from the URI.

推荐答案

回答我自己的问题:

看看在 https://stackoverflow.com/a/23620747/14731 中找到的createResource

这篇关于Jersey2:从资源导航到实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:30