Struts值栈与Ognl
来源:互联网 发布:如何使淘宝排名靠前 编辑:程序博客网 时间:2024/06/02 06:14
配置xml:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"><struts> <package name="stack" namespace="/stack" extends="struts-default"> <action name="stack_*" class="star.july.c_valuestack.StackAction" method="{1}"> <result name="success">/index.jsp</result> <result name="input">/add.jsp</result> </action> </package> </struts>
StackAction:
package star.july.c_valuestack;import java.util.Map;import star.july.b_validation.Student;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.util.ValueStack;public class StackAction extends ActionSupport{ Student student; public Student getStudent() { return student; } public void setStudent(Student student) { this.student = student; } public String stack(){ String name = student.getName(); ActionContext ac = ActionContext.getContext(); //使用对象栈存储对象 //获取值栈,用list的栈方式存取 ValueStack vs = ac.getValueStack(); //将对象放入栈中,压栈 vs.push(student); //弹栈 // vs.pop(); //使用映射栈存取对象 //添加自己的值和栈 Map map = ac.getContextMap(); map.put("map", "自定义"); //获取request Map rp = (Map)ac.get("request"); rp.put("rp", "请求"); //获取session Map sp = ac.getSession(); sp.put("sp", "会话"); //获取application并赋值 Map ap = ac.getApplication(); ap.put("ap", "应用"); System.out.println(student); return SUCCESS; }}
输入值:
<body> <s:fielderror></s:fielderror> <form action="<c:url value='/stack/stack_stack'/>" method="post"> 用户名:<input type="text" name="student.name"><br> <input type="submit" value="提交"/> </form>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib uri="/struts-tags" prefix="s" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <!-- 对象栈的取方式,用[] --> <!-- 取出方式,从下表开始一直取到结束为止 --> 对象栈的取方式,用[] <s:property value="[1]"/><br> <s:property value="[0]"/><br><br><br> <!-- 映射栈的取值方式,前面加# --> 映射栈的取值方式,前面加#<br> <s:property value="#map"/><br> <s:property value="#request.rp"/><br> <s:property value="#session.sp"/><br> <s:property value="#application.ap"/> <!-- 调试值栈,看值 --> <s:debug></s:debug> </body></html>
0 0
- Struts值栈与Ognl
- Struts中的OGNL与值栈
- OGNL 与 Struts 2
- 值栈与ognl
- 值栈与OGNL
- OGNL与值栈
- Ognl值栈对象及struts标签
- Ognl表达式与Struts标签
- Struts2学习——(六)值栈与OGNL表达式[结合struts标签]
- OGNL表达式与值栈
- Struts2-OGNL与值栈
- Struts中OGNL与EL表达式
- Struts中OGNL与EL表达式
- Struts中OGNL与EL表达式
- Struts中OGNL与EL表达式
- struts学习(五)—ognl和值栈
- struts ognl
- Struts-OGNL
- python 常用的内置函数
- 《Android编程权威指南》第二版 第二章 挑战练习
- Kalman filter 使用经验总结
- 【计算机网络-9】【第三章】广域网
- B/S 和 C/S
- Struts值栈与Ognl
- 单源最短路径算法-Dijkstra
- Java String类
- 写时拷贝的方式实现基本的String类
- 51NOD 1491 黄金系统 && Codeforces 458 A. Golden System(斐波那契数列 + 找规律)
- tHINKpHP认识---文件了解
- test
- Docker入门
- 【计算机网络-10】【第四章】网络层