我有一个自定义标记文件的forms: <h:form> <h:commandButton value="click"> <f:ajax event="click" listener="#{bean[method]}" /> </h:commandButton> </h:form> 我有条件地通过ajax如下所示: <h:panelGroup id="test"> <h:form> <h:commandButton value="click"> <f:ajax event="click" listener="#{backingTest.updateFlag}" render=":test"/> </h:commandButton> </h:form> <h:panelGroup rendered="#{backingTest.flag}"> <my:customtag bean="#{backingTest}" method="printMessage"/> </h:panelGroup> </h:panelGroup> 这是关联的支持bean: import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean @RequestScoped public class BackingTest { private boolean flag = false; public void printMessage() { System.out.println("hello"); } public void updateFlag() { […]