java - 如何隐藏我的网址参数?

标签 java jsp url portlet

我有几个带有一些链接的 Portlet,我想要的只是隐藏 URL 参数。因此,我认为包含一些 jQuery 代码会很容易,该代码为每个表单构建一个表单并在其上绑定(bind)一个单击事件以提交该表单。

这不起作用。由于某种原因,操作请求未得到满足。

有人对隐藏 URL 参数有不同的建议吗?

最佳答案

<a href="#" onclick="JavaScript: handleThisLink();"> description of link </a>
<form name="mydataform" id="mydataform" action="/actionurlonyoursite" method="post">
  <input type="hidden" name="myparam" value="" />
</form>
<script type="text/javascript">
function handleThisLink()
{
    // access the hidden element in which you wish to pass the value of the parameter
    dojo.byId("myparam").value = "myvalue";
    // the value might be precomputed (while generating this page) or 
    // might need to be computed based on other data in the page
    // submit the form by HTTP POST method to the URL which will handle it.
    document.forms['mydataform'].submit();
    // also possible to actually send a background AJAX request and publish
    // the response to some part of the current page, thus avoiding full
    // page refresh
    // I used dojo.byId() as a shortcut to access the input element
    // this is based on dojo toolkit.
}

</script>

关于java - 如何隐藏我的网址参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1716649/

相关文章:

java - 包含带有 Android 应用程序的文本文档

url - 亚马逊 S3 : Access Denied for URL using symbols

javascript - 使用动态 URL 查询参数提供静态目录

java - 如何一键对齐两个文本

java - gl_Normal 计算不正确

java - 我如何通过将鼠标悬停在标签上来获取 JLabel 的文本(带有图标)来解释标签是什么?

javascript - JQuery 无法解析 JSP EL

javascript - 如何在 JavaScript/jQuery 函数中使用表达式语言 (EL)?

javascript - 如何在 XML 中插入多个/不同的隐藏字段?

php - youtube 如何对他们的 url 进行编码?