struts2_day03_16_ognl表达式#使用_17_ognl表达式%使用
2017-12-05 16:24
381 查看
16_ognl表达式#使用
package com.hlg.valuestack;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ContextAction extends ActionSupport {
public String execute(){
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("req", "reqValue");
return "success";
}
}
--------------------------------------------------------------------------------------------------------------------------------------
17_ognl表达式%使用
<s:textfield name="username" value="%{#request.req}"></s:textfield>
<s:textfield name="username" value="%{#request.req}"></s:textfield>
package com.hlg.valuestack;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ContextAction extends ActionSupport {
public String execute(){
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("req", "reqValue");
return "success";
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="/struts-tags" prefix="s" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <s:property value="#request.req"/> </body> </html>
--------------------------------------------------------------------------------------------------------------------------------------
17_ognl表达式%使用
%使用
1 在struts2标签中表单标签 (1)在struts2标签里面使用ognl表达式,如果直接在struts2表单标签里面使用ognl表达式不识别,只有%之后才会识别。 |
<s:textfield name="username" value="%{#request.req}"></s:textfield>
相关文章推荐
- Struts2 使用OGNL表达式投影(过滤)
- S7.2_Struts2_OGNL OGNL表达式的投影和选择技术范例,OGNL表达式#和$符号的使用范例,以及值栈
- struts2_ognl表达式符号的使用方法
- Struts2使用16 -- 值栈与 OGNL 1 -- 概述
- Struts2的Ognl表达式的理解与使用
- 使用struts2中的ognl表达式调用类方法
- Struts2系统学习(16)OGNL表达式及基本原理分析
- Struts2中Ognl表达式的使用
- struts2对ognl表达式的使用(配图解加讲解)
- Struts2使用17 -- 值栈与 OGNL 2 -- 使用
- OGNL表达式和struts2中的使用
- struts2使用OGNL表达式访问方法与属性
- Struts2核心(二)----使用OGNL表达式
- Struts2的OGNL表达式的使用
- struts2的ognl表达式二:支持函数使用
- struts2 中 OGNL表达式的使用
- struts2教程(9)--OGNL表达式使用
- Struts2中使用OGNL表达式语言访问静态方法和静态属性以及我遇到的问题和解决方法
- Struts2 OGNL表达式的iterator标签使用详解
- 【OA】——Struts2 标签库和 OGNL表达式 使用小结