Hiding param value in URL - JSF Application
<h:outputLink value="#{beanname.path}">
<h:outputText value="Output label"></h:outputText>
<f:param name name="name" value="tommy"/>
</h:outputLink>
开发者_开发技巧http://127.0.0.1:7101/projectt/faces/index.jsp?name=tommy my URL appears with the param value. I want to hide it in the URL and get it in the bean class.
So, you want a POST request? Use <h:commandLink>
instead.
<h:form>
<h:commandLink value="Output label" action="#{beanname.outcome}">
<f:param name name="name" value="tommy"/>
</h:commandLink>
</h:form>
The parameter can be set as
@ManagedProperty("#{param.name}")
private String name;
or can passed by <f:setPropertyActionListener>
instead:
<h:form>
<h:commandLink value="Output label" action="#{beanname.outcome}">
<f:setPropertyActionListener target="#{beanname.name}" value="tommy"/>
</h:commandLink>
</h:form>
or when you're already on a Servlet 3.0 / EL 2.2 capable container (Tomcat 7, Glassfish 3, etc), just pass it as action method argument:
<h:form>
<h:commandLink value="Output label" action="#{beanname.outcome('tommy')}" />
</h:form>
with
public String outcome(String name) {
// ...
return "index";
}
精彩评论