Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JSF2中获取REST资源的链接_Rest_Jsf - Fatal编程技术网

如何在JSF2中获取REST资源的链接

如何在JSF2中获取REST资源的链接,rest,jsf,Rest,Jsf,比如说,我有一个简单的REST服务,可以获取PDF文件的内容: @Path("/pdf") @Stateless public class GroupSheetEJB { . . . @GET @Path("examsheet/{groupId: \\d+}/{course: \\d+}/{semester: \\d+}/{subjectId: \\d+}") @Produces("application/pdf") public Response examSheet(@Pat

比如说,我有一个简单的REST服务,可以获取PDF文件的内容:

@Path("/pdf")
@Stateless
public class GroupSheetEJB {

. . .
  @GET
  @Path("examsheet/{groupId: \\d+}/{course: \\d+}/{semester: \\d+}/{subjectId: \\d+}")
  @Produces("application/pdf")
  public Response examSheet(@PathParam("groupId") int groupCode, @PathParam("course") int course,
    @PathParam("semester") int semester, @PathParam("subjectId") int subjectCode) {
    try {
      StudyGroup grp = groups.get(groupCode);
      Subject sub = subjects.get(subjectCode);
      ResponseBuilder response = Response.ok(getExamSheet(grp, sub, course, semester));
      return response.build();
    } catch (Exception e) {
      throw new NotFoundException(e.getMessage());
    }
  }
}
是否有任何方法可以轻松地从
组件获取此REST服务的链接? 现在我使用纯HTML标记:

<a target="examsheet" href="#{request.contextPath}/webresources/#{semesterSubjectMarksMB.examSheetLink}">REST link</a>

output
参数的值为
/webresources/#{semestsubjectmarksmb.examSheetLink}
获取禁用的链接


致意。

如果
a
标记对您来说足够了,为什么要使用
h:link
?足够了,但我可以根据各种条件重新渲染。我只是想知道——也许有一些机制可以获取REST服务的路径。硬编码链接是好的解决方案吗?您可以在
ui:fragment
片段中包装
a
标记,以决定是否渲染。如果要使用JSF特定的标记,请改用
h:outputLink