继续使用JSF。您的要求如下所示:
查看(
test.xhtml)
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>JSF Hello World</title> </h:head> <h:body> <h:form> <h:commandButton value="Hey" action="#{bean.hey}"> <f:ajax render=":result" /> </h:commandButton> </h:form> <h:outputText id="result" value="#{bean.result}" /> </h:body></html>
型号(
Bean.java)
@ManagedBean@RequestScopedpublic class Bean { private String result; public void hey() { result = "Hello World!"; } public String getResult() { return result; }}
而已。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)