【发布时间】:2017-04-24 01:53:34
【问题描述】:
让以下代码片段包含指向items.xhtml 的链接,该链接列出项目名称并允许用户选择项目以查看其详细信息:
<?xml ... ?>
<!DOCTYPE ... >
<html ... >
<h:head>
<title>Welcome</title>
</h:head>
<h:body>
<h:outputLink value="#{facesContext.externalContext.requestContextPath}/faces/client/items.xhtml">Items</h:outputLink>
</h:body>
</html>
当用户单击名为Items 的链接时,请求行指出正在请求的资源是/javaee7-training/faces/client/items.xhtml,并且应该对其应用的所需操作是GET。没关系。
以下代码显示了items.xml的片段:
<?xml ... ?>
<!DOCTYPE ...>
<html ...>
<h:head>
<title>items</title>
</h:head>
<h:body>
<h:form prependId="false">
<h:selectOneRadio value="#{bean.itemId}"
layout="pageDirection">
<c:forEach items="#{bean.items}" var="itm">
<f:selectItem itemValue="#{itm.itemno}"
itemLabel="#{itm.itemname}" />
</c:forEach>
</h:selectOneRadio>
<h:commandButton value="Details" action="item" />
</h:form>
</h:body>
</html>
现在,当用户单击名为Details 的按钮时,请求行指出正在请求的资源是/javaee7-training/faces/client/items.xhtml,并且应该对其应用的所需操作是POST。我没想到会出现这个结果,因为当用户单击名为Details 的按钮时,请求的资源是/javaee7-training/faces/client/item.xhtml,而所需的操作是GET。
谁能解释一下这个结果以及为什么我错了?
提前谢谢你
【问题讨论】:
标签: jsf