[英]Failed to instantiate UriInfo Specified class is an interface
I want to use annotation @Context to retrieve the URI 我想使用注释@Context检索URI
@GetMapping(value = "/profile/{username}", produces = MediaType.APPLICATION_JSON_VALUE)
public Response getProfile(
@PathVariable String username,
@Context UriInfo uriInfo
) {
return Optional
.ofNullable(userService.findOneByUsername(username))
.map(user -> Response
.created(uriInfo.getAbsolutePathBuilder().path(username).build())
.status(Response.Status.OK)
.entity(user).build())
.orElseGet(() -> {
throw new ProfileNotFoundException();
});
}
However, while displaying the page throws an exception 但是,在显示页面时会引发异常
org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.ws.rs.core.UriInfo]: Specified class is an interface
I can not find information on how to fix. 我找不到有关如何修复的信息。
UriInfo
isn't a part Spring MVC. UriInfo
不是Spring MVC的一部分。 You can use @RequestParam
in Spring MVC for this 您可以在Spring MVC中使用
@RequestParam
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.