//显示Java 任意对象的代码如下
public class AdminUser {
private String account=null;
private String apasswd=null;
public AdminUser(String account,String apasswd){
this.account = account;
this.apasswd =apasswd;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getApasswd() {
return apasswd;
}
public void setApasswd(String apasswd) {
this.apasswd = apasswd;
}
}
//再是Controller中的java代码
public class AdminController extends Controller {
public void index() {
render("login1.html");
}
public void login() {
String account = getPara("account");
String apasswd = getPara("apassword");
System.out.println("Login Info:["+account+","+apasswd+"]");
if( null == account || account.length()==0 ){
render("login.html");
}
else {
setAttr("user", new AdminUser(account, apasswd));
render("index.html");
}
}
}
//index.html页面代码
<div class="nav-user">
<!-- 登入后的状态 -->
<a class="avatar" href="index.html">
<img src="res/images/8.jpg">
<cite style="color: white;">#(user.account)</cite>
<i style="color: white;">退出</i>
</a>
<div class="nav">
<a href="set.html"><i class="iconfont icon-shezhi"></i>设置</a>
<a href="login.html"><i class="iconfont icon-tuichu" style="top: 0; font-size: 22px;"></i>退了</a>
</div>
</div>
从上面可以看出,index.html获取的setAttr("user", new AdminUser(account, apasswd));
中user的两个属性account和apasswd的方法是 ===> #(user.account) <===
如果你的页面是jsp的话,再在网上百度下吧。
/**
* Field
*
* field 表达式取值优先次序,以 user.name 为例
* 1:假如 user.getName() 存在,则优先调用
* 2:假如 user 为 Model 子类,则调用 user.get("name")
* 3:假如 user 为 Record,则调用 user.get("name")
* 4:假如 user 为 Map,则调用 user.get("name")
* 5:假如 user 具有 public name 属性,则取 user.name 属性值
*/