flowExecutionUrl ajouté deux fois lors de l'utilisation de la balise th: action dans thymeleaf

StackOverflow https://stackoverflow.com//questions/21012649

Question

J'utilise thymeleaf avec Spring webflow et spring mvc.J'essaie d'obtenir l'URL de l'application enflowExecutionUrl .Mais quand j'imprime flowExecutionUrl en quelques instants, j'obtiens l'URL qui ressemble à

/SWF/loginflow.htm?execution=e2s1

mais quand je passe la même chose th:action le nom de mon projet a été ajouté deux fois.Comme ça

/SWF/SWF/loginflow.htm?execution=e2s1

ci-dessous mon code

<!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>
Était-ce utile?

La solution 2

Merci Tom pour ta réponse.j'ai trouvé la solution

<form id="myForm" th:action="${flowExecutionUrl}"
       th:object="${userDetail}" method="post">
       <input type="hidden" name="_eventId" value="loginCredentialsEntered" />

Et mon action sera

/SWF/loginflow.htm?execution=e3s2_eventId=loginCredentialsEntered

Autres conseils

Leth:action utilise le @{...} syntaxe, qui réécrit l’URL.Depuis le flowExecutionUrl commence par un /, l'URL est réécrite par rapport à la racine de contexte de votre application.Le chemin du contexte /SWF est ajouté au début de l'URL.

La travée ne l'utilise pas @ syntaxe et écrit ainsi simplement la valeur originale de flowExecutionUrl.

Vous devez supprimer le chemin de contexte du flowExecutionUrl et laissez Thymeleaf ajouter le chemin du contexte en utilisant le @ syntaxe, votre application ne dépend donc pas du chemin du contexte.

Source: Syntaxe d'URL standard de Thymeleaf

J'ai trouvé cette réponse ici:

Cela fonctionne très bien avec webflow et thymeleaf.

Utilisez des URL relatives au serveur comme expliqué ici : http://www.thymeleaf.org/doc/html/Using-Thymeleaf.html#link-urls

Cela ressemblerait à :

th:href="@{'~' + ${flowExecutionUrl}}"

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top