JSF in bean of type null
严重: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.el.PropertyNotFoundException: Error testing property 'userName' in bean of type null
at com.sun.faces.el.PropertyResolverImpl.getType(PropertyResolverImpl.java:342)
at com.sun.faces.el.impl.ArraySuffix.getType(ArraySuffix.java:240)
at com.sun.faces.el.impl.ComplexValue.getType(ComplexValue.java:208)
at com.sun.faces.el.ValueBindingImpl.getType(ValueBindingImpl.java:338)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:111)
我的face-config.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config >
<managed-bean>
<managed-bean-name>UserBean</managed-bean-name>
<managed-bean-class>
com.jsfdemo.bean.UserBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>userName</property-name>
<property-class>java.lang.String</property-class>
<value></value>
</managed-property>
<managed-property>
<property-name>password</property-name>
<property-class>java.lang.String</property-class>
<value></value>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>/userLogin.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/userLoginSuccess.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/userLogin.jsp</to-view-id>
</navigation-case></navigation-rule>
<navigation-rule>
<from-view-id>/userLoginSuccess.jsp</from-view-id>
</navigation-rule>
<application>
<locale-config>
<default-locale>zh_CN</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>ja</supported-locale>
</locale-config>
</application>
</faces-config>
我的userLogin.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSF 'userLogin.jsp' starting page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<f:view>
<f:loadBundle basename="com.jsfdemo.Messeages_zh_CN" var="bundle" />
<h:form>
<h:outputLabel for="userName" value="#{bundle.user_name_lable}" />
<h:inputText id="userName" value="#{userBean.userName}" required="true"/>
<h:outputLabel for="password" value="#{bundle.user_password_lable}" />
<h:inputSecret id="password" value="#{userBean.password}" rendered="true" required="true" /><br>
<h:commandButton type="submit" value="#{bundle.login_botoom_lable}" action="#{userBean.loginUser}"></h:commandButton>
</h:form>
</f:view>
</body>
</html>