JSF标记<h:inputtext>无法正常工作

时间:2017-11-24 19:40:53

标签: jsf jsf-2

我是JSF的新手,面临一个问题。我开发了一个包含标签APicture的小应用程序。当我执行应用程序时,它不显示文本输入部分。 以下是代码:

User.java: (Managed Bean)

<h:inputText>

Detail.xhtml: (创建用户注册详细信息)

package com.JSF.UIExample;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = "user", eager = true)
@RequestScoped
public class User {
    private String name;
    private String password;
    private String email;
    private String gender;
    private String address;

    public User(){  }
    // getter and setter
}

Response.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" 
xmlns:h="http://xmlns.jcp.org/jsf/html" 
xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
    <title>User Registration</title>
</h:head>

<h:body>
    <h:form id="form">
        <table>
            <tr>
                <td><h:outputLabel for="username"><b>Username:</b></h:outputLabel></td>
                <td><h:inputText id="name-id" value="#{user.name}" /></td>
            </tr>
            <tr>
                <td><h:outputLabel for="password"><b>Password:</b></h:outputLabel></td>
                <td><h:inputSecret id="password-id" value="#{user.password}" /></td>
            </tr>
            <tr>
                <td><h:outputLabel for="email">Email:</h:outputLabel></td>
                <td><h:inputText id="email-id" value="#{user.email}" /></td>
            </tr>
            <tr>
                <td><h:outputLabel for="gender">Gender:</h:outputLabel></td>
                <td><h:selectOneRadio value="#{user.gender}">
                        <f:selectItem itemValue="Male" itemLabel="Male" />
                        <f:selectItem itemValue="Female" itemLabel="Female" />
                    </h:selectOneRadio></td>
            </tr>
            <tr>
                <td><h:outputLabel for="address">Address:</h:outputLabel></td>
                <td><h:inputText id="address-id" value="#{user.address}" cols = "50" rows = "5" /></td>
            </tr>
        </table>
        <h:commandButton value = "Submit" action = "Response.xhtml"></h:commandButton>
    </h:form>
</h:body>
</html>

web.xml:

<!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:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
    <title>User Details</title>
</h:head>

<h:body>
    <h2>
        <h:outputText value="Hello #{user.name}" />
    </h2>
    <h4>You have been registered successfully. Following are your
        details</h4>
    <table>
        <tr>
        <td><b>Email:</b></td>
        <td><h:outputText value = "#{user.email}"/></td>
        </tr>
        <tr>
        <td><b>Gender:</b></td>
        <td><h:outputText value = "#{user.gender}"/></td>
        </tr>
        <tr>
        <td><b>Address:</b></td>
        <td><h:outputText value = "#{user.address}"/></td>
        </tr>
    </table>
</h:body>

Maven依赖:

<?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" 
   xmlns:web = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee 
   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   id = "WebApp_ID" version="2.5">

   <welcome-file-list>
      <welcome-file>faces/Detail.xhtml</welcome-file>
   </welcome-file-list>

   <!-- 
      FacesServlet is main servlet responsible to handle all request. 
      It acts as central controller.
      This servlet initializes the JSF components before the JSP is displayed.
   -->

   <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>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.xhtml</url-pattern>
   </servlet-mapping>

</web-app>

xmlns的两个xhtml文件中:h =&#34; http://xmlns.jcp.org/jsf/html" 显示警告无法找到facelet标记uri http://xmlns.jcp.org/jsf/html的图书馆 &安培; xmlns:f =&#34; http://xmlns.jcp.org/jsf/core" 显示警告无法找到uri http://xmlns.jcp.org/的facelet标记库 有人能告诉我哪里出错了。

1 个答案:

答案 0 :(得分:1)

对于2.2之前的JSF版本,您需要使用旧的r_port = new QSerialPort(this); r_port->setPortName("COM3"); r_port->setBaudRate(QSerialPort::Baud9600); r_port->setDataBits(QSerialPort::Data8); r_port->setParity(QSerialPort::NoParity); r_port->setStopBits(QSerialPort::OneStop); r_port->setFlowControl(QSerialPort::NoFlowControl); if (r_port->open(QSerialPort::ReadWrite)) { connect(r_port, &QSerialPort::readyRead, this, &MYPROG::on_readyRead); connect(r_port, &QSerialPort::errorOccurred, this, &MYPROG::breakCaught); } else { QMessageBox::critical(this, "SERIAL PORT NOT CONNECTED", "Unable to connect to the radio.\n\nPlease check your connections\nand configuration and try again."); return; } void MYPROG::on_readyRead() { // keep reading until we get a \r\n delimiter rxBytes.append(r_port->readAll()); qDebug()<<"raw rxBtes"<<rxBytes; if(!rxBytes.contains("\r\n")) { return; } int end = rxBytes.lastIndexOf("\r\n") + 2; QStringList cmds = QString(rxBytes.mid(0, end)).split("\r\n", QString::SkipEmptyParts); rxBytes = rxBytes.mid(end); foreach(QString cmd, cmds){ qDebug()<<"serial read"<<cmd; } } 命名空间。

  

旧命名空间| JSF 2.2命名空间

     

http://java.sun.com/jsf/core | http://xmlns.jcp.org/jsf/core

     

http://java.sun.com/jsf/html | http://xmlns.jcp.org/jsf/html

     

http://java.sun.com/jsf/facelets | http://xmlns.jcp.org/jsf/facelets

     

http://java.sun.com/jsf/composite |   http://xmlns.jcp.org/jsf/composite

     

http://java.sun.com/jsp/jstl/core |   http://xmlns.jcp.org/jsp/jstl/core

     

http://java.sun.com/jsp/jstl/functions |   http://xmlns.jcp.org/jsp/jstl/functions

另见: