Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单的JSF项目,面临404和500问题_Jsf_Jsf 2 - Fatal编程技术网

简单的JSF项目,面临404和500问题

简单的JSF项目,面临404和500问题,jsf,jsf-2,Jsf,Jsf 2,我试着从同一个问题的主题中找到解决方案,但这对我不起作用。这就是我的故事。我创建了一个非常简单的web项目: 代码如下: package user.bean; import javax.annotation.ManagedBean; @ManagedBean public class User { private String firstName; private String lastName; private String email; User()

我试着从同一个问题的主题中找到解决方案,但这对我不起作用。这就是我的故事。我创建了一个非常简单的web项目:

代码如下:

package user.bean;

import javax.annotation.ManagedBean;

@ManagedBean
public class User {

    private String firstName;
    private String lastName;
    private String email;

    User() {

    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}
第一个JSF:

<!DOCTYPE html>

<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:head>    
        <title>User Registration Form</title>        
        <style>
            .error {color:red}
        </style>        
    </h:head>

     <h:body>
        <h:form>        
            <h:messages styleClass="error"/>        
            First Name: <h:inputText value="#{user.firstName}" 
                                     label="First name"/>
            <br/><br/>          
            Last Name: <h:inputText value="#{user.lastName}" 
                                    label="Last name" 
                                    required="true"/>
            <br/><br/>          
            Email: <h:inputText value="#{user.email}" 
                                    label="Email" 
                                    required="true"/>
            <br/><br/>          
            <h:commandButton value="Submit" action="user_response"/>            
        </h:form>
    </h:body>
</html>
我有:NLS缺少消息:无法在中找到\u FACELET\u标记库: org.eclipse.jst.jsf.core.validation.internal.facelet.messages

我试过:

关闭/重新打开项目

右键单击项目>验证

项目>清理。。。并清理选定的项目

重新启动Eclipse

它不起作用

当我运行它时,我遇到了:HTTP状态404 所以我试了一下:

单击窗口>显示视图>服务器或右键单击中的服务器 服务器视图,选择属性

在“常规”面板中,单击“开关位置”按钮

位置:[工作区元数据]应替换为其他内容

双击服务器,打开服务器的概览屏幕

在服务器位置选项卡中,选择使用Tomcat位置

保存配置并重新启动服务器

然后通过属性->Java构建路径添加JSF2.2 Mojarra 2.2.0。没有变化。所以我从构建路径中删除它并添加到WEB-INF->lib。在服务器和面上运行:Servlet Faces的HTTP状态500-Servlet.init Servlet引发异常。我在我的web.xmp中添加了url模式和侦听器:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>JSF</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>  
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>
并面临HTTP状态404-/JSF/user_form.xhtml


嗯,我现在完全是个新手,如果你能帮我一点忙,我会非常感激的。谢谢。

您尝试了哪些主题?请参见我尝试的主要主题:
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>JSF</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>  
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>