2017-02-01 18 views
3

私はthymeleaf、html、angularjs、js、およびspringブートを使用してWebアプリケーションを作成しています。私の主な質問は、入力値を保持して、その値を次のページの入力ボックスに表示させる方法です。htmlでリダイレクトされた後の入力値の保持方法

例:右上の検索バーに質問を入力するとスタックオーバーフローが発生し、リダイレクトされ、以前に入力した値と同じ値を持つ新しい検索バーが表示されます。

Here's the example

Index.htmlと

<form action="getDetails" method="POST"> 

<p> Mac Address: </p><input type="text" name="inputMacAddress" id="inputMacAddress" required="required" placeholder="Enter Mac Address" /> 

<br/> 

<input type="submit" value="Submit" class="marginButton"/> <input type="reset" value="Clear" onclick="Redirect();" class="marginButton" /> 
     <script> 
     function Redirect() 
     { 
      window.location.href = 'http://www.localhost:8080';    
     } 
    </script> 

     </form> 

getDetails.html

<form action="getDetails" method="POST"> 

<p> Mac Address: </p><input type="text" name="inputMacAddress" id="inputMacAddress" required="required" placeholder="Enter Mac Address" /> 

<br/> 

<input type="submit" value="Submit"/> <input type="reset" value="Clear" onclick="Redirect();" /> 
     <script> 
     function Redirect() 
     { 
      window.location.href = 'http://www.localhost:8080';    
     } 
    </script> 

     </form> 
+0

を見てみましょうか? – AymDev

+2

URLクエリパラメータを確認してください –

+0

@AymDev PHPを使用したくありません。 –

答えて

3

あなたのアプリで角度のルートを使用していますか?リダイレクト(角度コードからリダイレクトしていることを前提とします)では、URLにクエリパラメータを追加し、$routeParamsを使用して2番目のページにクエリパラメータを取得できます。

+0

routeParamsの簡単な例を教えてもらえますか? –

0

GETまたはPOSTを使用してパラメータを渡す必要があります。ほとんどの場合、GETが使用されます。例: http://localhost.html?q="Hello+world"

そして、そのGET値を入力に渡します。

はあなたがPHPを知らないか、あなたはそれを使用したくない$routeParamshere

関連する問題