我正在尝试使用intelliJ上的maven模块创建一个简单的登录webapp。
这是java类:
package com;
public class Login {
private String userName;
private String password;
public Login(){}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String checkValidUser()
{
if(userName.equals("test") && password.equals("test"))
return "true";
else return "false";
}
}
这是jsp:
<%@ page contentType="text/html"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<f:view>
<html>
<head><title>Testare login</title></head>
<body>
<h:form>
<table>
<tr>
<td><h:outputText value="Enter Login ID: " /></td>
<td><h:inputText value="#{Login.userName}" /></td>
</tr>
</table>
</h:form>
</body>
</html>
</f:view>
这是faces-config.xml文件:
<?xml version="1.0"?>
<!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>Login</managed-bean-name>
<managed-bean-class>com.Login</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
当我进入页面时,在我的输入框中我得到了这个:#{Login.userName}。 有谁知道我做错了什么?