我尝试制作简单的 JSF 示例并有几个文件管理器。我使用 Maven,并存储在 META-INF flolder faces-confid.xml 中。
在尝试执行时的输出中,我看到:
Welcome to JSF.
但它必须是:
Welcome to JSF. test
他们来了:
豆文件
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
@Named("test")
@RequestScoped
public class TestBean implements Serializable{
private String test = "test";
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
}
XHTML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Welcome</title>
</h:head>
<h:body>
<h3>Welcome to JSF. #{test.test}</h3>
</h:body>
</html>