struts2 session 1(通过ActionContext class中的方法getSession得到)
来源:互联网 发布:大数据分析技术现状 编辑:程序博客网 时间:2024/05/21 17:55
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><display-name>StrutsTutorial</display-name><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><package name="login" extends="struts-default"><action name="test" class="action.TestAction"><result name="success">/show.jsp</result></action></package></struts>
java
package action;import java.util.Map;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;public class TestAction extends ActionSupport{@Overridepublic String execute(){ActionContext actionContext = ActionContext.getContext(); Map session = actionContext.getSession(); session.put("USER_NAME", "Test User"); return SUCCESS; }}
jsp
<%@ page contentType="text/html; charset=utf-8" language="java"%><%@taglib prefix="s" uri="/struts-tags"%><html><head></head><body><s:property value="#session.USER_NAME"/></body></html>
- struts2 session 1(通过ActionContext class中的方法getSession得到)
- struts2生成session的方法:ActionContext.getContext().getSession()
- 在struts2 中通过ActionContext访问Session对象
- Map<String, Object> session=ActionContext.getContext().getSession()
- Struts2中的ActionContext
- Struts2中的ActionContext
- struts2中的actionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext
- struts2中的ActionContext
- Struts2中的ActionContext
- Struts2中的ActionContext详解
- 拿什么来拯救你,我的table
- 想念那一池莲花
- android_Activity系列 activity的生命周期
- 创建第一个WCF服务
- 扩展jQuery对json字符串的转换
- struts2 session 1(通过ActionContext class中的方法getSession得到)
- 访问嵌入式网页出错:The requested URL '/' resolves to a file which is marked executable but is not a CGI file
- 指针、数组名、地址的区别
- android 提高进程的优先级
- Prototype(java原型模式)
- 房屋租赁行业丢人事件
- oracle(10 R2) linux(centos 6.2) 下安装
- WPF 点击按钮,根据路劲打开.exe应用程序
- php系统函数