1、Struts2中的同包跳转方式
1.1)Action跳转JSP
forward(跳转) struts2默认跳转页面是forward
redirect(跳转) <result name="ok" type="redirect">/index.jsp</result>
1.2)Action跳转Action
forward(跳转) <result name="ok" type="chain">action名称</result>
redirect(跳转) <result name="ok" type="redirectAction">action名称</result>
2、含有命名空间(namespace)跳转方式
2.1) Actiont跳转JSP(同上)
forward(跳转) struts2默认跳转页面是forward
redirect(跳转) <result name="ok" type="redirect">/index.jsp</result>
2.2)Action跳转Action
<result name="ok" type="chain|redirectAction" >
<param name="namespace">/emp</param>
<param name="actionName">queryAll</param>
</result>
说明:type是设置跳转的类型,chain是forward跳转,redirectAction是重定向跳转
第一个param中的name是namespace固定写死,第二个param中的name是actionName也是固定写死,并区分大小写
3、ONGL表达式:
ONGL表达是的作用:获取值栈中的数据
ONGL表达式取值要求:只能在root区和contextMap区中取值
3.1)获取root区中的数据
1、直接获取一个被存在root区中的对象 User{name,age }------------->取值name
2、直接获取一个被存在root区中对象的对象 User(name,age,Address(id,aname))----->取值user.address.id
3、直接获取一个被存在root区中的对象list属性 User(name,age,list)--------->取值user.list[下标]
4、直接获取一个被存在root区中的对象Map属性 User(name,age,map<String,Striung>)---->取值user.map['key']
6、OGNL可以进行相应的运算 + - * / > < = == && || !等
7、OGNL获取的数据可以调用该数据类型的相关方法:user.name.toUpperCase()
3.2)从ContextMap中取值
与root区取值基本一致 ,只需要在加个“#”
如:request作用域中list集合存在contextMap中,取 #request.list
session作用域中user存在contextMap中,取 #request.user