flowExecutionUrl se agrega dos veces mientras se usa la etiqueta th:action en thymeleaf
-
21-12-2019 - |
Pregunta
Estoy usando thymeleaf con Spring webflow y spring mvc.Estoy intentando obtener la URL de la aplicaciónflowExecutionUrl
.Pero cuando imprimo flowExecutionUrl
en span obtengo la URL que es como
/SWF/loginflow.htm?execution=e2s1
pero cuando paso lo mismo en th:action
El nombre de mi proyecto se añadió dos veces.Como esto
/SWF/SWF/loginflow.htm?execution=e2s1
a continuación está mi código
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring3-3.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div>
<div style="width: 1330px; height: 100px;">
<div id="header" th:include="'/header'::headerfream"></div>
</div>
<div style="width: 1330px; height: 500px; position: absolute; top: 110px;">
<form action = "#" th:action="@{${flowExecutionUrl}}" method="POST">
<div>
<table>
<tr><td><span th:text="${flowExecutionUrl}"></span></td></tr>
<tr>
<td>
<p>User Name</p>
</td>
<td>
<input type="text" name="name" id="name" />
</td>
</tr>
<tr>
<td>
<p>Password</p>
</td>
<td>
<input type="password" name="password" id ="password" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit"/>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
</body>
</html>
Solución 2
Gracias Tom para su respuesta.Encontré la solución
<form id="myForm" th:action="${flowExecutionUrl}"
th:object="${userDetail}" method="post">
<input type="hidden" name="_eventId" value="loginCredentialsEntered" />
y mi acción será
/swf/loginflow.htm?execution=E3S2_EVENTID=LOGInCredentialSented
Otros consejos
Elth:action
utiliza el @{...}
sintaxis, que reescribe la URL.desde el flowExecutionUrl
comienza con un /
, la URL se reescribe en relación con la raíz de contexto de su aplicación.El camino del contexto /SWF
se antepone a la URL.
El lapso no usa esto. @
sintaxis y por lo tanto simplemente escribe el valor original de flowExecutionUrl
.
Deberías eliminar la ruta de contexto del flowExecutionUrl
y deje que Thymeleaf anteponga la ruta de contexto usando el @
sintaxis, por lo que su aplicación no depende de la ruta de contexto.
Encontré esta respuesta aquí :
Funciona con WebFlow y Thymeleaf muy bien.
Utilice las URL de servidor-relativas como se explica aquí: http://www.thymeleaf.org/doc/html/using-thymeleaf.html#link-urls
Esto se vería como:
th: href="@ {'~' + $ {flowexecutionurl}}"