后台获取

  值类型  request.getSession().setAttribute("username", user.getUserName());
  对象类型   request.getSession().setAttribute("user", user);

前台应用 

值:

<br>
用struts标签: <s:property value="#session.username" />
<br>
用EL表达式:${session.username}
<br>
用java代码:<%=session.getAttribute("username")%>
<br>

对象
<br>
用struts标签: <s:property value="#session.user.userName" />
<br>
用EL表达式:${session.user.password}
<br>
用java代码:<%=session.getAttribute("user")%>
<br>

前台上传表单页面

	<s:form action="login1">
		用户<s:textfield name="user.userName" type="text"/>
		<s:textfield name="user.password" key="pass" />
		<s:textfield name="password" key="pass" />
		<s:submit key="login" />
	</s:form>

后台获取

对象

private User user;
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }
    

//与前台页面name="password" 一致
    public void setPassword(String password) {
        this.password = password;
    }

 

posted on 2016-10-17 16:34  艾恩格朗特  阅读(271)  评论(0编辑  收藏  举报