SpringBoot踩坑指南(一):超链接--不能不经过请求直接跳转到新的html及a标签传值

本篇博文转自:https://blog.csdn.net/qq_36688143/article/details/79499959

html链接传值及在新html取值和显示上一步操作封装的属性信息(显示刚才创建的文件夹、发表的文章等)点击打开链接

 a标签遍历list传值、传请求:

    <table class="table table-hover">
		<tr>
			<th>id</th>
			<th>folder</th>
			<th>功能一</th>
			<th>功能二</th>
		</tr>
		<tr th:each="lFolder : ${session.lFolders}">
		
			<td th:text="${lFolder.id}"></td>
			<td th:text="${lFolder.folder}"></td>
            <td> 
            	<a th:href="@{/uploadTwo?(id=${lFolder.id})}">上传</a>
            </td>
            
            <td> 
            	<a th:href="@{/queryFolder?(id=${lFolder.id})}">查看</a>
            </td>
           
		</tr>
	</table>

****************************************************************************************************************************************

window.location.href = "signin";

1)这个代码的意思是跳转到signin这个请求,SpringBoot会根据Controller中的RequestMapping找到"/signin"请求,然后执行里面的内容,并不是跳转到"signin.html"

****************************************************************************************************************************************

window.location.href = "signin.html";

2)这个代码的意思是跳转到"signin.html"页面,但是要注意:如果这个html是放在templates下,那么跳转就会失败,因为服务器会把"signin.html"当成一个请求,原理跟上面第一点一样。

  原因:动态html直接请求就可以访问,程序的安全性就会很弱,不安全。如果非要这样子直接跳转页面,请看第三点。

****************************************************************************************************************************************

3)如果需要直接超链接跳转到页面,而不经过请求,那就把要跳转的页面放在static下,没有这个文件夹就新建就好。

扫描二维码关注公众号,回复: 4291161 查看本文章

猜你喜欢

转载自blog.csdn.net/Anglebeat/article/details/84591036
今日推荐