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

查看:30
本文介绍了隐藏从 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.

推荐答案

要隐藏传递的参数,实际上需要提交表单.您应该阻止单击事件的默认行为并将其替换为表单事件.像在这个例子中那样做

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天全站免登陆