1. 程式人生 > >Struts ognl表示式語言幾個符號

Struts ognl表示式語言幾個符號

#  獲取非根元素值  、 動態都建map集合

$  配置檔案取值

%  提供一個ognl表示式執行環境

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags"  prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <
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"> </head> <body> <br/>獲取request域資料<
br/> <!-- property 標籤是物件型別的標籤,預設支援ognl表示式, 會從根元素去China名稱對應的值 --> <s:property value="China"/> <br/> <!-- 如果直接賦值,需要用單引號 --> <s:property value="'China'"/> <br/> <s:property value="#request.cn"/> <br/>
<s:property value="%{#request.cn}"/> <br/> <!-- 同上 --> <!-- 值型別的標籤,value值預設就是值型別,不支援ognl表示式 --> 國家:<s:textfield name="txtCountry" value="%{#request.cn}"></s:textfield> </body> </html>