【发布时间】:2017-06-18 10:26:29
【问题描述】:
我正在使用 thymeleaf、html、angularjs、js 和 spring boot 来创建 Web 应用程序。我的主要问题是如何保留输入值并将该值显示在下一页的输入框中?
示例:当您在右上角的搜索栏中键入问题时,堆栈溢出,您会被重定向,并且您还会获得一个新的搜索栏,该搜索栏的值与您之前输入的相同。
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>
【问题讨论】:
-
你不懂PHP还是不想用?
-
查看 URL 查询参数
-
@AymDev 不想使用 PHP。
-
URL 查询、cookie、localstorage,让后端在 POST 之后返回它,使用角度路由......这么多选项。此外,SO 可能不会重新加载标题,因此标题实际上并没有改变。
标签: javascript html angularjs thymeleaf