以下是我的支持 bean:
@Component("resume")
@Scope("session")
@Document
public class Resume implements ResumePlan,Serializable {
private static final long serialVersionUID = -5332235643191283709L;
@Id
private String id;
@DBRef
private Objective objective;
@DBRef
private PersonalDetails personalDetails;
.....
//getter and setters
.....
public String putResumeToDB()
{
System.out.println("HELOOOOOOOOOOOOOOOOOOOOOOOOOOO"+this);
return "Success";
}
..........
}
以下是 jsf 文件:
<h:form>
<p:panel id="panel" header="Personal Details">
<p:messages id="msgs" />
<h:panelGrid columns="3">
<h:outputLabel for="objective" value="Objective: " />
<p:inputTextarea id="objective" rows="2" cols="80"
counter="counter0" maxlength="100"
value="#{resumeBuilder.resume.objective.objective}"
counterTemplate="{0} characters remaining." autoResize="false">
</p:inputTextarea>
<h:outputText id="counter0" />
<h:outputLabel for="name" value="Name: *" />
<p:inputText id="name"
value="#{resumeBuilder.resume.personalDetails.name}"
required="true">
<f:validateLength minimum="8" />
</p:inputText>
<p:message for="name" display="icon" />
.............
</h:panelGrid>
<p:commandButton id="btn" value="Save"
action="#{resume.putResumeToDB}" >
</p:commandButton>
</p:panel>
</h:form>
我的服务器是tomcat7。
当我在表单中输入值并检查 System.out.println 以查看支持 bean 值时,我得到以下信息:
HELOOOOOOOOOOOOOOOOOOOOOOOOOOOResume [id=null, objective=null, personalDetails=null, skills=null, experience=null, education=null, references=null, publications=null]
当我输入表单中的所有值时,为什么支持 bean 是空的。我究竟做错了什么?我在 mongodb 中使用 spring 数据进行数据持久性。我在 faces-config.xml 中创建了 el-resolver 条目
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
并在 web.xml 中包含以下条目:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
谢谢