将传递的参数从jsp隐藏到struts2动作类 [英] hide passed parameter from jsp to struts2 action class

查看:100
本文介绍了将传递的参数从jsp隐藏到struts2动作类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<s:url action="someAction" var="act">
<s:param name="param1">value1</s:param>
</s:url>
<s:a href="%{act}">Go Action</s:a>

点击Go Action链接,地址将为 www.example.com / someAction?param1 = value1
我想在提交表单时隐藏传递的参数(param1 = value1),如method =POST。无论如何我能做到吗?谢谢。

By clicking Go Action link, the address will be www.example.com/someAction?param1=value1 I want to hide passed parameters (param1=value1) like method="POST" in submitting of form. Is there anyway I can do it? Thanks.

推荐答案

要隐藏传递的参数,您需要提交表单。您应该阻止click事件的默认行为并将其替换为form事件。在这个例子中这样做

To hide passed parameter actually you need to submit the form. You should prevent the default behavior of the click event and replace it with the form event. Do it like in this example

<s:form id="f1" action="someAction">
  <s:hidden name="param1" value="value1"/>
  <s:url action="someAction" var="act"/>
  <s:a id="a1" href="%{act}">Go Action</s:a>
  <script type="text/javascript">
    $(document).ready(function() {
      $("#a1").click(function(event) {
        event.preventDefault();
        $("#f1").submit();
      });
    });
  </script>
</s:form>

这篇关于将传递的参数从jsp隐藏到struts2动作类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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