Struts2 displayTag

790 views Asked by At

unfortunately, i'm trying to use Struts2 displayTag i want to pass a list of clients to my table using displayTag but i'm getting an error the following code is my action:

package presentation;

public class AdminAction extends ActionSupport
{

private String nom;
private String prenom;
private String cin;
private String login;
private String password;

private List<Client> clients = new ArrayList<>();

public String ajouterClient()
{

    Client client = new Client();

    client.setNom(nom);
    client.setPrenom(prenom);
    client.setLogin(login);
    client.setCin(cin);
    client.setPassword(password);

    if(AdminMetier.ajouterClient(client)!= false)
    {
        return Action.SUCCESS;
    }

    return Action.ERROR;
}


public String listerClients()
{

    this.setClients(AdminMetier.getClients());

    return Action.SUCCESS;
}


public String getNom() {
    return nom;
}
public void setNom(String nom) {
    this.nom = nom;
}
public String getPrenom() {
    return prenom;
}
public void setPrenom(String prenom) {
    this.prenom = prenom;
}
public String getCin() {
    return cin;
}
public void setCin(String cin) {
    this.cin = cin;
}
public String getLogin() {
    return login;
}
public void setLogin(String login) {
    this.login = login;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}


public List<Client> getClients() {
    return clients;
}


public void setClients(List<Client> clients) {
    this.clients = clients;
}

}

this is my struts.xml file

<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>

<package name="module-login" namespace="/login" extends="struts-default">

    <action name="verifier" class="presentation.LoginAction" method="verifierLogin">
        <result name="model.Client">/vuesJSP/client/client.jsp</result>
        <result name="model.Administrateur" type="redirectAction">
        /vuesJSP/admin/ajouterClient.jsp
        <param name="actionName">lister</param>
        <param name="namespace">/admin</param>
        </result>
        <result name="error">/vuesJSP/login/login.jsp</result>
        <result name="input">/vuesJSP/login/login.jsp</result>
    </action>

</package> 

<package name="module-Admin" namespace="/admin" extends="struts-default">

    <action name="ajouter" class="presentation.AdminAction" method="ajouterClient">
    <result name="success">/vuesJSP/admin/ajouterClient.jsp</result>
    <result name="error">/vuesJSP/admin/ajouterClient.jsp</result>
    <result name="input">/vuesJSP/admin/ajouterClient.jsp</result>
    </action>

    <action name="modifier" class="presentation.AdminAction" method="modifierClient">
    </action>

    <action name="supprimer" class="presentation.AdminAction" method="supprimerClient">
    </action>

    <action name="lister" class="presentation.AdminAction" method="listerClients">
    <result name="success">/vuesJSP/admin/listeClients.jsp</result>
    <result name="error">/vuesJSP/admin/listeClients.jsp</result>
    <result name="input">/vuesJSP/admin/listeClients.jsp</result>
    </action>

</package>

this is the declaration of my display tag in a jsp page

<display:table name="clients" requestURI="lister">
<display:column property="nom" title="Nom"/>
<display:column property="prenom" title="Prenom"/>
<display:column property="cin" title="CIN"/>
<display:column property="login" title="Login"/>
<display:column property="password" title="Password"/>
</display:table>

the name of the given error is :

javax.servlet.ServletException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/commons/lang/UnhandledException
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
1

There are 1 answers

7
Roman C On BEST ANSWER

This is a dependency that you should add

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.4</version>
</dependency>