您的位置:首页 > 编程语言 > Java开发

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";
}

}


<%@ 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>

<s:textfield name="username" value="%{#request.req}"></s:textfield>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: