0
XHTML文件我用viewParam:JSF viewParam沒有設置
<?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">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<f:metadata>
<f:viewParam name="actionId" value="#{editActionView.actionId}" required="true" />
</f:metadata>
<h:body>
的支持bean如下所示:
EditActionView.java
@ManagedBean
@ViewScoped
public class EditActionView {
private long actionId;
@PostConstruct
void init() {
System.out.println("actionId: " + getActionId());
}
public long getActionId() {
return actionId;
}
public void setActionId(long actionId) {
this.actionId = actionId;
}
當我現在請我的應用程序:
http://localhost:8080/aip/editAction.jsf?actionId=37
actionId始終是0.我的錯在哪裏?
hm ...我想基於GET參數初始化我的後備bean。我將如何檢索該值? – matthias
這是一個很好的答案:[http://stackoverflow.com/questions/9844526/when-to-use-fviewaction-prerenderview-versus-postconstruct](http://stackoverflow.com/questions/9844526/when-to -use-fviewaction-prerenderview-versus-postconstruct)。總結:您可以使用''(自JSF 2.2以來)或''(JSF 2.0,2.1) –
Tomek