zoukankan      html  css  js  c++  java
  • struts2笔记之struts:property标签

    1、访问ActionContext资源request,session,parameters

    (1)、action实现ServletRequestAware接口,并且重写setServletRequest()

    // request对象,不用设置get方法,只须重写set方法
        private HttpServletRequest request; 
    
    @Override
        public String execute() throws Exception {
            // TODO Auto-generated method stub
    ...........
    request.setAttribute("list", list); request.setAttribute("dPage", dPage);
    ...........
    }
    @Override
    public void setServletRequest(HttpServletRequest arg0) { // TODO Auto-generated method stub this.request = arg0; }

    (2)jsp调用request中的值或方法

    <s:property value="#request.dPage.get()" default="10"/>
    <s:property value="#request.list" default="10"/

    2、 访问Action值栈中的对象或方法或对象的属性或对象的方法:(要求get-set方法)

    2.1 要求action中的对象有get -set方法,而且对象名最好不要有大写字母,容易出错

    2.2 如果要访问对象的其他属性或方法,这写属性方法也要get-set

    2.3 示例:

    <s:property value="attrName"/>
    
    <s:property value="methodName()"/>
    
    <s:property value="dpage.currentPage" default="0"/>
    
    <s:property value="dpage.getpageCount()" default="0"/>

    12,投影

    <s:property value="listName.{?#this.age==1}"/>

    <s:property value="listName.{^#this.age>1}"/>

    <s:property value="listName.{$#this.age==1}"/>

    <s:property value="listName.{$#this.age==1}.{age}==null"/>

    <s:property value="[0]"/>值栈中的对象

    Done!

  • 相关阅读:
    Linux(Contos7.5)环境搭建之JDK1.8安装(二)
    python微信域名或者链接批量检测
    表单设计器3-查询面板
    表单设计器2-表格布局
    表单设计器1-基本操作
    信息无障碍国内标准
    信息无障碍国际标准
    信息无障碍服务对象
    信息无障碍定义
    E8.Net工作流开发问题
  • 原文地址:https://www.cnblogs.com/xingyyy/p/3432124.html
Copyright © 2011-2022 走看看