zoukankan      html  css  js  c++  java
  • struts tags 学习

    property


    value 的类型是  object
    则<s:property value="username" />   -----------------------------------------------------------1                          
    这里的username被当做ognl表达式

    如果我们想要显示字符串只能这样写<s:property value="'username'" />

    如果是ognl表达式,则上面1式中就会调用当前action中的getUserName的方法来获取username的值。


    Set
    The set tag assigns a value to a variable in a specified scope. It is useful when you wish to assign a variable to a complex expression and then simply reference that variable each time rather than the complex expression. This is useful in both cases: when the complex expression takes time (performance improvement) or is hard to read (code readability improvement).

    set标签主要是用来将一个复杂的表达式用一个简单的变量进行替换,以后只需读取这个变量就可以读取复杂表达式的值。
    <s:set name="personName" value="person.name"/>
    Hello, <s:property value="#personName"/>. How are you?
    这里将person.name在action context里面设定一个变量personName,之后我们通过property标签将这个值读取出来


    The scopes available are as follows :-


    • application - the value will be set in application scope according to servlet spec. using the name as its key

    • session - the value will be set in session scope according to servlet spec. using the name as key

    • request - the value will be set in request scope according to servlet spec. using the name as key

    • page - the value will be set in page scope according to servlet sepc. using the name as key

    • action - the value will be set in the request scope and Struts' action context using the name as key




    If no scope is specified, it will default to action scope.(request 和 ActionContext)

    Include
    <s:set var="incPage" value="%{'/_include1.html'}" />
    <s:include value="%{#incPage}"></s:include>
    include标签的value的类型是string,所以这里就会产生一个问题:如何在include里面使用ognl表达式,这里就引出了%的用法






  • 相关阅读:
    Permutations II
    N-Queens II
    Palindrome Number
    Minimum Path Sum
    JS的DOM操作2
    JS 的DOM操作
    函数概念
    JavaScript数组
    JavaScript循环及练习
    JS语言
  • 原文地址:https://www.cnblogs.com/feiling/p/2579943.html
Copyright © 2011-2022 走看看