JSF入門例、表示情報
index.xhtml
Bean:
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title>myjsf</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</h:head>
<h:body>
<h:form id="form">
<div style="padding: 100px 0 0 100px; font-size: 22px; font-weight: bold">
Hello,#{testBean.name}!
</div>
</h:form>
</h:body>
</html>
Bean:
/**
*
*/
package com.vs.myjsf.bean;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
/**
* @author hadoop
*
*/
@ManagedBean(name="testBean")
@SessionScoped
public class TestBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -9220754931689983991L;
private String name = "ming.ming";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}