我有奇怪的问题。我有一个带有两个控件的 JSF 页面: - InputText - 按钮
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="view12.jsf" id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:inputText label="Label 1" id="it98" value="#{param.test}" editable="always"/>
<af:commandButton actionListener="#{bindings.przekierowanie.execute}" text="przekierowanie"
disabled="#{!bindings.przekierowanie.enabled}" id="cb1"/>
</af:form>
</af:document>
我想用 URL 中的参数初始化 InputText(参数名称是 test - value="#{param.test}")。在 JSF 页面中一切都很好。但是单击按钮后,我必须从 Java 代码中的 InputText 读取值,所以我有 URL:
http://127.0.0.1:7101/Application6-ViewController-context-root/faces/view12.jsf?test=asd
单击按钮后执行的我的Java代码是:
public String przekierowanie() {
Map <String,String> map=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String tttValue=map.get("test");
System.err.println("test:" + tttValue);
return null;
}
但这不起作用......每次我点击按钮时都会得到空值。你能告诉我为什么以及如何从我的 java 函数中的 InputTex 获取这个值吗?