how to use tag in strut 1.2?

前端 未结 3 1979
星月不相逢
星月不相逢 2021-01-05 07:09

How to Use tag in Struts 1.2.

In name attribute, what value have to be used? Is bean name your property name?

3条回答
  •  萌比男神i
    2021-01-05 07:45

    Javadoc for :

    Specifies the attribute name of the bean whose property is accessed to retrieve the value specified by property (if specified). If property is not specified, the value of this bean itself will be rendered.

    In essence, if you have a JavaBean (with getters and setters),

    Person person = new Person;
    request.setAttribute("person", person);
    

    by setting , you're telling Struts to first find person object first from PageContext scope. If not found, then request, then session, then application scope.

    The property="age" attribute (from tag), will then call the getter method getAge() from the Person object (irrespective of whether there's an instance variable called age on the bean).

    Hope this helps.

提交回复
热议问题