1.访问servletAPI方法1
1 public String execute() throws Exception { 2 //request域对象==》map (struts2并不推荐使用原生request域对象) 3 //不推荐 4 Map<String, Object> requestScope = (Map<String, Object>) ActionContext.getContext().get("request"); 5 //推荐 6 ActionContext.getContext().put("name", "requestTom"); 7 //session域对象==》map 8 Map<String, Object> sessionScope = ActionContext.getContext().getSession(); 9 sessionScope.put("name", "sessionTom"); 10 //application域对象==》map 11 Map<String, Object> applicationScope = ActionContext.getContext().getApplication(); 12 applicationScope.put("name", "applicationTom"); 13 return SUCCESS; 14 }
1 request:${requestScope.name}<br> 2 session:${sessionScope.name}<br> 3 application:${applicationScope.name}<br>