使用JSF显示消息

时间:2017-06-19 22:52:00

标签: jsf

我在JSF中是全新的。我正在使用本教程:https://www.tutorialspoint.com/jsf 根据它,我创建了第一个项目。这是Java代码:

package com.tutorialspoint.test;
import javax.faces.bean.ManagedBean;

@ManagedBean(name = "helloWorld", eager = true)
public class HelloWorld {

    public HelloWorld() {
        System.out.println("HelloWorld started!");
    }

    public String getMessage() {
        return "Hello World!";
    }

}

这是home.xhtml文件:

<!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">
<head>
  <title>JSF Tutorial!</title>
</head>

<body>
#{helloWorld.getMessage()}
</body>
</html>

当我在浏览器中输入此地址时:http://localhost:8080/helloworld/home.jsf标签&#34; JSF教程!&#34;显示但内容(文字&#34; Hello World&#34;没有。我可以问你一些提示可能会遗漏的内容吗? 如果您需要其他文件中的更多信息/代码,请告诉我。 顺便说一句,我使用Wildfly 10.1.0作为应用程序服务器,我部署了更新的.war文件。 提前谢谢。

0 个答案:

没有答案