我试图显示托管bean的String值,但我认为xhtml页面根本看不到bean,因为UI中的值始终为空。
这是该bean的代码,试图显示getMod()的返回值
@ManagedBean(name="user")
@SessionScoped
public class WebTest implements Serializable{
@PostConstruct
public void init() {
}
ScheduleModel model = new ScheduleModel();
public String mod = model.getName();
public String getMod() {
return mod;
}
public void setMod(String mod) {
this.mod = mod;
}
}
这是xhtml div
<?xml version='1.0' encoding='UTF-8' ?>
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:th="http://www.thymeleaf.org"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<ui:include src="header.xhtml"/>
<body class="skin-blue">
<div class="wrapper">
<div class="form-group">
<label>value="#{user.getMod}" </label>
<br/>
<input type="text" class="form-control" placeholder="Name" />
</div>