Struts 2 make dynamic parameter

我是研究僧i 提交于 2019-12-11 07:45:02

问题


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>

回答1:


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;



回答2:


You have to set jsonObject when this action class has been called. So according to set parameter it will set parameter dynamic.



来源:https://stackoverflow.com/questions/18748564/struts-2-make-dynamic-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!