Struts 2制作动态参数 [英] Struts 2 make dynamic parameter

查看:70
本文介绍了Struts 2制作动态参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Struts2和JavaScript.我想编辑参数值或使用JavaScript将参数添加到URL以创建动态参数.我无法为param设置值,为什么没有id.还有其他形式的事情吗?

I am using Struts2 and JavaScript. I want to edit a parameter value or add parameter to URL with JavaScript to make dynamic parameter. I can not set value for param why this not have id. Any other form of do?

var urle = document.getElementsByName("vari");          
    urle.value = 5;

<s:url var="urlex" action="actionDo"><s:param name="vari" value=""/></s:url>

推荐答案

Struts标记是在服务器上编译和执行的JSP标记,JavaScript是在客户端浏览器上执行的.您必须先发出Ajax请求,才能从javascript代码访问服务器.但是您也不需要.使用

Struts tags are JSP tags that compiled and executed on server, JavaScript is executed on client browser. You can't access the server from javascript code without making ajax request. But you don't need too. Use

var url = '<s:url var="urlex" action="actionDo">' +'?vari=' + val;

这篇关于Struts 2制作动态参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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