html <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <title>JSF Example</title> </h:head> <h:body> <h1>Welcome to JSF Example</h1> <h:form> <h:outputLabel value="Name: "/> <h:inputText value="#{userData.name}"/><br/> <h:outputLabel value="Email: "/> <h:inputText value="#{userData.email}"/><br/> <h:commandButton value="Submit" action="#{userData.save}"/><br/> </h:form> </h:body> </html> import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean @SessionScoped public class UserData implements Serializable { private String name; private String email; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String save() { return "success"; } } <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd" version="2.2"> </faces-config>


上一篇:
下一篇:
切换中文