Javascript 在html中重定向后,如何保留输入值?
我正在使用thymeleaf、html、angularjs、js和springboot创建一个web应用程序。我的主要问题是,我如何能够保留一个输入值,并将该值显示在下一页的输入框中 示例:堆栈溢出当您在右上角的搜索栏中键入问题时,您会被重定向,并且还会得到一个新的搜索栏,该搜索栏的值与您以前输入的值相同 Index.htmlJavascript 在html中重定向后,如何保留输入值?,javascript,html,angularjs,thymeleaf,Javascript,Html,Angularjs,Thymeleaf,我正在使用thymeleaf、html、angularjs、js和springboot创建一个web应用程序。我的主要问题是,我如何能够保留一个输入值,并将该值显示在下一页的输入框中 示例:堆栈溢出当您在右上角的搜索栏中键入问题时,您会被重定向,并且还会得到一个新的搜索栏,该搜索栏的值与您以前输入的值相同 Index.html <form action="getDetails" method="POST"> <p> Mac Address: </p>
<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>
<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>
Mac地址:
函数重定向(){
window.location.href=http://www.localhost:8080';
}
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" class="marginButton"/> <input type="reset" value="Clear" onclick="Redirect();" class="marginButton" />
<script>
function Redirect() {
window.location.href = 'http://www.localhost:8080';
}
</script>
</form>
<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>
Mac地址:
函数重定向(){
window.location.href=http://www.localhost:8080';
}
您的应用程序中是否使用角度路由?在重定向中(假设您是从angular代码重定向),您可以将查询参数添加到URL,并使用在第二页上获取它们。您需要使用GET或POST传递参数。在大多数情况下,使用GET。
e、 g.http://localhost.html?q=“你好+世界”
然后将GET值传递给输入
查看
$routeParams
您不了解PHP或不想使用它?查看URL查询Parameters@AymDev不想使用PHP.URL查询、cookie、localstorage,让后端在发布后返回它,使用角度路由。。。有这么多选择。另外,可能不会重新加载标题,因此标题实际上不会更改。您能给我一个简单的routeParams示例吗?