Struts 2 If, ElseIf, Else exemple de tag

Struts 2 If, ElseIf, exemple de balise Else

Téléchargez-le -Struts2-If-ElseIf-Else-Tag-Example.zip

Les balises Struts 2If, ElseIf and Else sont utilisées pour effectuer la vérification des conditions de base.

La balise «If» peut être utilisée seule


    This is String 1

ou avec la balise «Else If»


    This is String 1


    This is String 2

and/or single/multiple ‘Else‘ tag.


    This is String 1


    This is String 2


    Other Strings

Toutes les déclarations ci-dessus sont correctes. Voyons un exemple pour illustrer l’utilisation de la balise Struts 2 ‘If, ElseIf and Else’.

1. action

Une classe Action avec une propriété String, qui contient une valeur «Struts 2».

IfTagAction

package com.example.common.action;

import com.opensymphony.xwork2.ActionSupport;

public class IfTagAction extends ActionSupport{

    private String framework = "Struts 2";

    public String getFramework() {
        return framework;
    }

    public void setFramework(String framework) {
        this.framework = framework;
    }

    public String execute() {
        return SUCCESS;
    }
}

2. Exemple de balise If, ​​ElseIf et Else

Une page JSP pour montrer l'utilisation de la baliseIf, ElseIf and Else pour effectuer la vérification de la condition sur la variable «framework».

if.jsp

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




Struts 2 If, Else, ElseIf tag example

This is Struts 2 This is Struts 1 Other framework

3. struts.xml

Liez-le ~






    

    

        
            pages/if.jsp