隐藏 Struts 2 中 URL 标签传递的参数 [英] Hide parameter passed by URL Tag in Struts 2

查看:47
本文介绍了隐藏 Struts 2 中 URL 标签传递的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Struts 2 应用程序中,我使用迭代器标记并使用各自的 getter 和 setter 从数据库获取值表.例如,我正在获取帐号、姓名和帐户余额的列表.

In my Struts 2 Application, I am getting a table of values from the database using the iterator tag and using respective getter and setters for the same. For Example I am getting list of Account number, Name and Account Balance.

现在我没有做的是,如果有人点击帐号,那么请求将被发送到另一个需要 getter 和 setter 的操作类,并将他重定向到一个页面,在该页面上将显示帐户详细信息在那个帐号上.

Now What I wasnt to do is if some one click on the Account number, then the request will be sent to another action class which has required getter and setter and will redirect him to a page where the account details will be shown based on that account number.

问题在于,当用户点击 url 时,value 像 get 参数一样传递,因此非常不安全.我想隐藏这些值.

Problem is that, as the user clicks the url, value is passed like get parameters so it is very insecure. I want to hide the values.

目前我正在使用以下内容:

Currently I am using the following:

<s:url action="custACDetails" var="urlTag" >
    <s:param name="yourAc"><s:property value="acno"/></s:param>
</s:url>
<a href="<s:property value="#urlTag" />" ><s:property value="acno"/></a>

推荐答案

您可以添加一个表单来触发表单提交事件,而不是默认链接的 click 事件.表单应该包含一个隐藏字段来保存参数值.然后添加 javascript 代码来处理 click 事件.

You can add a form to trigger a form submit event instead of default link's click event. A form should contain a hidden field to hold a parameter value. Then add javascript code to handle click event.

<s:url action="custACDetails" includeContext="false" var="urlTag"/>
<s:set var="contextPath">${pageContext.request.contextPath}</s:set>
<s:a id="acno" href="%{#contextPath+#urlTag}"><s:property value="acno"/></s:a>
<s:form id="form" action="%{#urlTag}" method="POST">
  <s:hidden name="yourAc" value="%{acno}"/>
</s:form>
<script type="text/javascript">
  $(document).ready(function() {
    $("#acno").click(function(e) {
      e.preventDefault();
      $("#form").submit();
    });
  });
</script>

这篇关于隐藏 Struts 2 中 URL 标签传递的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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