`
shoppingbill
  • 浏览: 58322 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

url或get中文参数传递取值

阅读更多
这几天做项目时遇到了个问题就是我想通过<a href="XX/XX.do?name="中文" ">XX </a> 这个时候不会报错也不显示name。于是寻求解决方案:
用js创建一个post form 在jsp页面上把参数传进来
dynamicform.js
function openHref(myAction, paramName, paramValue) {
	var submitForm = getNewSubmitForm();
	createNewFormElement(submitForm, paramName, paramValue);
	//up to 4 parameters
	for (var i = 3; i < 11; i = i + 2) {
		if ((arguments[i] != undefined) && (arguments[i + 1] != undefined)) {
			createNewFormElement(submitForm, arguments[i], arguments[i + 1]);
		}
	}
	submitForm.action = myAction;
	submitForm.submit();
}

  //helper function to create the form
function getNewSubmitForm() {
	var submitForm = document.createElement("FORM");
	document.body.appendChild(submitForm);
	submitForm.method = "POST";
	return submitForm;
}

  //helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue) {
	var newElement = document.createElement("input");
	newElement.setAttribute("name", elementName);
	newElement.setAttribute("type", "hidden");
	newElement.setAttribute("value", elementValue);
	inputForm.appendChild(newElement);
	return newElement;
}

导入js
<script type="text/javascript" src="${pageScope.path}/common/js/dynamicform.js"></script>	

调用如下:

 <a href="javascript:openHref('${pageScope.path}/searchScripts.do?param=searchScriptByName','script_name','${scripts.script_name}','tenant_id','${scripts.tenant_id}');">${scripts.script_name}</a>
分享到:
评论

相关推荐

    HTML5&CSS3网页制作:创建表单.pptx

    method属性用于设置表单数据的提交方式,其取值为get或post。 method属性 name属性用于指定表单的名称,以区分同一个页面中的多个表单。 name属性 autocomplete属性用于指定表单是否有自动完成功能。 autocomplete...

    PHP培训教程之AJAX技术.docx

    open("method","URL")建立对器的调用,个参数HTTP请求可以为GET,POST或任何器所支持的您想调用的。 第二个参数请求页面的URL。 send()方法,具体请求 abort()方法,停止当前请求! readyState属性请求的状态有5个...

    EL表达式 (详解)

    取得请求的URL,但不包括请求之参数字符串 ${pageContext.request.contextPath} 服务的web application 的名称 ${pageContext.request.method} 取得HTTP 的方法(GET、POST) ${pageContext.request.protocol}...

    jdbc基础和参考

    getConnection(url,properties); getConnection(url,user,passwd); 2.直接调用Driver.connect方法执行 Driver d = new DriverClass(); d.connect(url,properties); 3.创建Statement: Statement: 1....

    出现问题a is defined高手帮忙

    // get globals G.mapPosition = DragZoomUtil.getElementPosition(mapDiv); G.buttonDiv = buttonDiv; G.backButtonDiv = backButtonDiv; G.mapCover = zoomDiv; G.map = map; G.borderCorrection = G....

    html入门到放弃笔记

    -- 能正常显示中文 2、&lt;body&gt;&lt;/body&gt; 属性: 1、text ,取值是一个颜色值(red,green,blue...) 2、bgcolor ,取值也是一个颜色值 Demo : 在刚才的 Demo 基础上 1、在 &lt;html&gt;中 增加 &lt;head&...

    javascript入门笔记

    Javascript Basic 1、Javascript 概述(了解) ... 调用函数时,所传递的参数列表,称之为"实参(实际参数)" 3、练习 1、定义一个函数 change ,该函数中接收两个参数(a,b) 2、在函数体中,如果 a 大于 b的话...

    js使用小技巧

    网页传递参数 location.search(); 可编辑 obj.contenteditable=true 执行菜单命令 obj.execCommand 双字节字符 /[^x00-xff]/ 汉字 /[u4e00-u9fa5]/ 让英文字符串超出表格宽度自动换行 word-wrap: ...

    freemarker总结

    5、 方法:通过传递的参数进行计算,以新对象返回结果 方法变量通常是基于给出的参数计算值在数据模型中定义。 6、 用户自定义FTL指令:宏和变换器 7、 节点 节点变量表示为树型结构中的一个节点,通常在XML...

    ExtAspNet v2.2.1 (2009-4-1) 值得一看

    -一个典型应用,在Window控件中打开新页面,如果传递的参数不正确,则首先提示参数不对然后关闭此弹出窗口。 -ExtAspNet.Alert.Show("参数错误!", String.Empty, ExtAspNet.ActiveWindow.GetCloseReference());...

    ExtAspNet_v2.3.2_dll

    -一个典型应用,在Window控件中打开新页面,如果传递的参数不正确,则首先提示参数不对然后关闭此弹出窗口。 -ExtAspNet.Alert.Show("参数错误!", String.Empty, ExtAspNet.ActiveWindow.GetCloseReference());...

Global site tag (gtag.js) - Google Analytics