0

I am using Struts2 and I'm having this apparently common issue, but I couldn't solve it with any of the answers i've found.

struts.xml

<action name="eliminarJug" class="tdp.proyectoWeb.ManejadorJugadorAction" method="executeEliminarJugador" > 
    <interceptor-ref name="storeStack" />       
    <result name="success" type="redirectAction">
        <param name="actionName">verInformacionPartidoAdmin</param>
        <param name="IdPartido">${IdPartido}</param>
    </result>
    <result name="error" type="redirectAction">
        <param name="actionName">verInformacionPartidoAdmin</param>
        <param name="IdPartido">${IdPartido}</param>            
    </result>                    
</action>

class

public String executeEliminarJugador(){     

    if ((nombre.equals("") && apellido.equals("")) || (nombre.equals("null") && apellido.equals("null"))){
        addActionError(getText("Jugador no encontrado."));
        return "success";
    }

    lista=new ListaJugadores();

    boolean res=lista.eliminarJugador(nombre, apellido);

    if (res){
        addActionMessage(getText("Jugador eliminado."));
        return "success";
    }
    else{
        addActionError(getText("Jugador no encontrado."));
        return "error";
    }

}

JSP

<s:form>
    <s:textfield placeholder="ID del Partido" class="text"  cssClass="txtEdit" name="IdPartido" required="true" value="%{#parameters.IdPartido}" hidden="true"/>
    <s:textfield placeholder="Nombre" class="text" cssClass="txtEdit"
        name="nombre" required="true" />
    <s:textfield placeholder="Apellido" class="text" cssClass="txtEdit" name="apellido" required="true" />
    <s:submit action="eliminarJug" cssClass="boton"
        value="Eliminar Jugador" />
    <s:submit action="vistaListaPartidosAdmin" cssClass="boton"
        value="Volver" />
</s:form>

This works perfectly when the result is "success", but when it comes to "error", I get "No result defined for action tdp.proyectoWeb.ManejadorJugadorAction and result input".

After trying a lot of things, I noticed that if I change

<result name="error" type="redirectAction">
    <param name="actionName">verInformacionPartidoAdmin</param>
    <param name="IdPartido">${IdPartido}</param>            
</result>   

for this...

<result name="error">SomeJSP.jsp</result>

It works fine, looking that the problem is in redirectAction.


Neuron
  • 5,141
  • 5
  • 38
  • 59
Ivan
  • 69
  • 6

0 Answers0