Servlet中的代码:
request.setAttribute("methodId", method);
request.setAttribute("infos",infos);
request.setAttribute("currentPage", String.valueOf(currentPage));
request.setAttribute("count", count);
request.setAttribute("pageCount",pageCount);
request.getRequestDispatcher("Index.jsp").forward(request,response);
其中method的值为String类型:
String method = request.getParameter("method");
js代码为:
window.onload = function changColor(){
var systemId = getQueryString("methodId");
if(systemId == null){
var currentA = document.getElementById("ITSM");
currentA.style.color = "#FFCC00";
}
else {
var currentA = document.getElementById(systemId);
currentA.style.color = "#FFCC00";
}
}
function getQueryString(name){
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
实现的功能是将对应的文字颜色初始化。
这种方式我在之前的项目中用过,现在无法从Servlet中取值了,各位大神,帮忙分析下