javahtmljspstruts2ognl

Struts2 s:url for a image in s:submit not working


I have a JSP with this form:

<s:form action="GestionPagos.action">
    <s:hidden key="actividad.id" />
    <s:submit type="image" 
        src="<s:url value ="/Internal Resources/imagenes/alta.png"/>">
    </s:submit>
</s:form>

But, when I try to render it in my browser, struts throws this error:

org.apache.jasper.JasperException: /Private/GestionCalendarios/MenuCalendario.jsp (línea: 144, columna: 1) /Private/GestionCalendarios/ListadoActividadColaboradores.jsp (línea: 51, columna: 64) Tag <s:submit not ended

I'm pretty sure that this tag worked before, but after a update, it didn't work anymore.

I can make it work using a classic HTML input tag, or splitting the button into two steps: using the url tag with a variable and then, using in the src field of the submit. But I want to know why isn't working together and what is the correct form of the tag.


Solution

  • You can't use struts tags inside the tag attribute. You are also don't need to provide action extension to the action attribute of the s:form tag. Rewrite it like

    <s:url var="imgUrl" value ="/Internal Resources/imagenes/alta.png"/>
    <s:form action="GestionPagos">
        <s:hidden name="actividad.id" />
        <s:submit type="image" src="%{#imgUrl}"/>
    </s:form>