Struts 2.3 中创建request,session,C标签输出session

Struts 2.3 中创建request两种方法

 

1.实现ServletRequestAware接口

 

public class UserAction extends BaseAction implements ModelDriven<User>,ServletRequestAware {

 

HttpServletRequest request;

session=request.getSession();

session.setAttribute("LoginUser", sessionInfo);

 

@Override

public void setServletRequest(HttpServletRequest request) {

this.request=request;

 

}

 

2.获得 context

request = ServletActionContext.getRequest();

 

输出session 

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:out value= "${LoginUser.loginName}"  />

 

 

你可能感兴趣的:(session)