*********** index.jsp *************
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<title>
填写个人信息
</title>
</head>
<body bgcolor="#ffffff">
<h1>
欢迎填写在线简历
</h1>
<f:view>
<h:form>
<h:panelGrid columns="2"> <h:outputText value="姓名:"/>
<h:panelGroup>
<h:inputText value="#{form.name}" required="true" id="name" size="20" />
<h:message for="name" style="color:red" />
</h:panelGroup> <h:outputText value="出生年份:" />
<h:selectOneListbox size="1" value="#{form.birthYear}">
<f:selectItems value="#{form.yearListItems}"/>
</h:selectOneListbox> <h:outputText value="外语语种:"/>
<h:selectManyListbox value="#{form.languages}">
<f:selectItems value="#{form.languageList}"/>
</h:selectManyListbox> <h:outputText value="您掌握的技能:"/>
<h:selectManyCheckbox value="#{form.skills}">
<f:selectItems value="#{form.skillSets}" />
</h:selectManyCheckbox> <h:outputText value="请选择您相应的职业:"/>
<h:selectOneRadio value="#{form.designation}">
<f:selectItems value="#{form.designationList}"/>
</h:selectOneRadio> <h:outputText value="是否允许通过电子邮件联系您?"/>
<h:selectBooleanCheckbox value="#{form.contactMe}"/> </h:panelGrid>
<h:commandButton value="提交简历" action="showDetails" />
</h:form>
</f:view>
</body>
</html>************success.jsp*************
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<title>
欢迎填写在线简历
</title>
</head>
<body bgcolor="#ffffff">
<h1>您的详细信息为</h1>
<f:view>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="姓名:"/>
<h:outputText value="#{form.name}"/> <h:outputText value="出生年份:"/>
<h:outputText value="#{form.birthYear}" /> <h:outputText value="外语:"/>
<h:outputText value="#{form.languageConcatenated}"/> <h:outputText value="技能:"/>
<h:outputText value="#{form.skillsConcatenated}"/> <h:outputText value="应聘的职位:"/>
<h:outputText value="#{form.designation}"/> <h:outputText value="希望通过电子邮件联系你:"/>
<h:outputText value="#{form.contactMe}"/>
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>**********faces-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 xmlns="http://java.sun.com/JSF/Configuration">
<managed-bean>
<managed-bean-name>form</managed-bean-name>
<managed-bean-class>jsfprj.ExampleBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>showDetails</from-outcome>
<to-view-id>/success.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
<h:selectOneListbox size="1" value="#{form.birthYear}">
<f:selectItems value="#{form.yearListItems}"/>
</h:selectOneListbox> <h:outputText value="外语语种:"/>
<h:selectManyListbox value="#{form.languages}">
<f:selectItems value="#{form.languageList}"/>
</h:selectManyListbox> <h:outputText value="您掌握的技能:"/>
<h:selectManyCheckbox value="#{form.skills}">
<f:selectItems value="#{form.skillSets}" />
</h:selectManyCheckbox> <h:outputText value="请选择您相应的职业:"/>
<h:selectOneRadio value="#{form.designation}">
<f:selectItems value="#{form.designationList}"/>
</h:selectOneRadio> <h:outputText value="是否允许通过电子邮件联系您?"/>
<h:selectBooleanCheckbox value="#{form.contactMe}"/>把这些去掉,就可以了.具体原因还要分析..
birthYearList.add(new SelectItem(new Integer(i)));
改成
birthYearList.add(new SelectItem(new Integer(i).toString()));
原因是:
public void setBirthYear(String birthYear) {
System.out.println("设置birthYear");
this.birthYear = birthYear;
}
里面用的参数是String的...success页面显示的东西也有问题,自己再处理一下吧.