这几天做项目时遇到了个问题就是我想通过<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>
分享到:
相关推荐
method属性用于设置表单数据的提交方式,其取值为get或post。 method属性 name属性用于指定表单的名称,以区分同一个页面中的多个表单。 name属性 autocomplete属性用于指定表单是否有自动完成功能。 autocomplete...
open("method","URL")建立对器的调用,个参数HTTP请求可以为GET,POST或任何器所支持的您想调用的。 第二个参数请求页面的URL。 send()方法,具体请求 abort()方法,停止当前请求! readyState属性请求的状态有5个...
取得请求的URL,但不包括请求之参数字符串 ${pageContext.request.contextPath} 服务的web application 的名称 ${pageContext.request.method} 取得HTTP 的方法(GET、POST) ${pageContext.request.protocol}...
getConnection(url,properties); getConnection(url,user,passwd); 2.直接调用Driver.connect方法执行 Driver d = new DriverClass(); d.connect(url,properties); 3.创建Statement: Statement: 1....
// get globals G.mapPosition = DragZoomUtil.getElementPosition(mapDiv); G.buttonDiv = buttonDiv; G.backButtonDiv = backButtonDiv; G.mapCover = zoomDiv; G.map = map; G.borderCorrection = G....
-- 能正常显示中文 2、<body></body> 属性: 1、text ,取值是一个颜色值(red,green,blue...) 2、bgcolor ,取值也是一个颜色值 Demo : 在刚才的 Demo 基础上 1、在 <html>中 增加 <head&...
Javascript Basic 1、Javascript 概述(了解) ... 调用函数时,所传递的参数列表,称之为"实参(实际参数)" 3、练习 1、定义一个函数 change ,该函数中接收两个参数(a,b) 2、在函数体中,如果 a 大于 b的话...
网页传递参数 location.search(); 可编辑 obj.contenteditable=true 执行菜单命令 obj.execCommand 双字节字符 /[^x00-xff]/ 汉字 /[u4e00-u9fa5]/ 让英文字符串超出表格宽度自动换行 word-wrap: ...
5、 方法:通过传递的参数进行计算,以新对象返回结果 方法变量通常是基于给出的参数计算值在数据模型中定义。 6、 用户自定义FTL指令:宏和变换器 7、 节点 节点变量表示为树型结构中的一个节点,通常在XML...
-一个典型应用,在Window控件中打开新页面,如果传递的参数不正确,则首先提示参数不对然后关闭此弹出窗口。 -ExtAspNet.Alert.Show("参数错误!", String.Empty, ExtAspNet.ActiveWindow.GetCloseReference());...
-一个典型应用,在Window控件中打开新页面,如果传递的参数不正确,则首先提示参数不对然后关闭此弹出窗口。 -ExtAspNet.Alert.Show("参数错误!", String.Empty, ExtAspNet.ActiveWindow.GetCloseReference());...