使用带HTML锚标签的POST方法 [英] Using the POST Method with HTML Anchor Tags

查看:152
本文介绍了使用带HTML锚标签的POST方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信答案是'不',但我想问问,只要
incase我错过了什么。

大家都知道,使用
GET方法将数据传递给锚标记中的页面:我想知道是否有办法做同样的事情,但使用
的POST方法呢?



我这样做的目的是保持用户看到的URL不是纯
把它们不需要看到的东西放到它们中。



这与我已经知道的安全问题无关如果答案确实不是,那么人们用什么方法来传递数据
何时需要保持URL清洁?饼干?还有其他什么?



以及如何在URL长度超过允许的GET请求长度时处理场景

在使用displaytag实现排序/分页时,我遇到了这个问题,所有的请求参数都附加在排序/分页url中,这超过了GET请求的允许长度。

 < form id =myform method =postaction =target.html> 
< input type =hiddenname =namevalue =value/>
< a onclick =document.getElementById('myform')。submit();>点击此处< / a>
< / form>


I am certain the answer will be 'NO', but I wanted to ask anyway just incase I have missed something.

Everyone knows that one pass data to a page in an anchor tag by using the GET method:

What I am wondering is if there was a way to do the same thing, but use the POST Method instead?

My purpose in doing so is to keep the URLs the user sees clean by not putting anything in them that they do not need to see.

This has nothing to do with security concerns as I already know there would be ways to obtain the data being passed.

If the answer is indeed no, then what methods do people use to pass data when there is a desire to keep the URLs clean? Cookies? Something else?

and how to deal with the scenarios when the URL length exceeds the permissible GET request length

I am facing this issue while implementing sorting/pagination with displaytag, all the request parameters are appending in the sort/pagination url which is more then the permissible length of the GET request.

解决方案

You could do something like this:

<form id="myform" method="post" action="target.html">
  <input type="hidden" name="name" value="value" /> 
  <a onclick="document.getElementById('myform').submit();">click here</a>
</form>

这篇关于使用带HTML锚标签的POST方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆