zoukankan      html  css  js  c++  java
  • Struts2 OGNL表达式

    1:Struts标签库的位置

     2:使用OGNL表达式前 需要在JSP中导入Struts2的标签库

      <%@ taglib prefix="s" uri="/struts-tags" %>

    
    
    

    3:输出标签

              <S:property value = ""  />  :如果不写value输出的值 那么默认输出栈顶的值。

    测试的Action

    public class OGNLDemo extends ActionSupport {
    
        public String testOgnl(){
        
         //1:
    ServletActionContext.getRequest().setAttribute(
    "a","aaaaaaa"); //将值存入map的栈顶
         //2:
    Person p = new Person(); p.setName("hello"); ValueStack v = ServletActionContext.getValueStack(ServletActionContext.getRequest());//将对象放入对象栈顶 v.push(p); System.out.println("Hello struts2' debug"); return "success"; } }

    页面取值的方式:

          <s:debug></s:debug>
          1: 对象中取值: <s:property value="name"></s:property>
          2: Map栈中取值:<s:property value="#request.a"></s:property>

    结果
             

    4:输出标签 主要用于输出集合的例如List,Map

              <S:iterator value="" var=""  status />  :

     

     

    特别注意表单中的value

     
















































    坚持
  • 相关阅读:
    语法树,短语,直接短语,句柄
    理解文法和语法
    了解编译原理
    实习日记7.20
    实习日记7.19
    实习日记7.18
    实习日记7.15
    实习日记7.13-7.14
    实习日记7.12
    实习日记7.11
  • 原文地址:https://www.cnblogs.com/gaoSJ/p/12986155.html
Copyright © 2011-2022 走看看