1
我有以下的Java代碼:更新H:用的outputText逃逸= 「假」 和值,包含 ' u001c'
@Named
@SessionScoped
public class TestClass implements Serializable {
private String stringValue;
@PostConstruct
private void init() {
initStringValueDefault();
}
public void initStringValue1() {
stringValue = "ABCD";
}
public void initStringValue2() {
stringValue = "EFGH" + '\u001c';
}
public void initStringValueDefault() {
stringValue = "LABEL TEXT";
}
public String getStringValue() {
return stringValue;
}
}
和.xhtml
<h:form id="testForm" prependId="true">
<h:outputText id="stringValueLabel" value="#{testClass.stringValue}" escape="false"/>
<br/>
<h:commandButton value="Set ABCD" actionListener="#{testClass.initStringValue1()}">
<f:ajax execute="@form" render="stringValueLabel"/>
</h:commandButton>
<span style="margin-left: 10px"/>
<h:commandButton value="Set EFGH + \u001c" actionListener="#{testClass.initStringValue2()}">
<f:ajax execute="@form" render="stringValueLabel"/>
</h:commandButton>
<span style="margin-left: 10px"/>
<h:commandButton value="Set default" actionListener="#{testClass.initStringValueDefault()}">
<f:ajax execute="@form" render="stringValueLabel"/>
</h:commandButton>
</h:form>
當我點擊'設置ABCD'按鈕,更新成功。但是,單擊「設置EFGH + \ u001c」我得到的錯誤後:
- 鉻:「在本地主機頁面:8080說:emptyResponse:一個空的響應是從服務器接收到的。」
- 火狐: 'malformedXML:XML解析錯誤:沒有很好地形成'
和標籤尚未更新。在頁面重新加載標籤更新爲'EFGH'後。
任何人都知道,爲什麼由於向變量添加'\ u001c',點擊按鈕後更新不起作用?
使用escape =「true」一切正常,但我需要escape =「false」。
你說這工作沒有'F:ajax'? – Kukeltje