У меня есть страница JSP, которая загружает содержимое другой страницы JSP, которая работает отлично. Проблема в том, что я хочу передать request.getParameter("cfgname")
на эту страницу контента, чтобы при ее загрузке в основную JSP контент был готов. (Текущий код показывает мне null
вместо request.getParameter
Вот моя главная страница JSP, которая получает cfgid=41&cfgname=Abhishek&cfgdesc=test1&cfgtype=Development&filepath=files%2Fcsmclientbuckeye.xml
<title>Testing</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.get("content.jsp", addContent);
function addContent(data)
{
$("#content").html(data);
}
});
</script>
</head>
<body>
<div id="content"></div>
</body>
Страница Content.jsp
<table class="csm-table" width="100%" cellspacing="0" cellpadding="4" border="0">
<tbody>
<tr>
<th width="25%">Configuration Name</th>
<td width="25%"><span id="cname"><%= request.getParameter("cfgname") %></span></td>
<th width="25%">Host Name</th>
<td width="25%"><span id="chostname">{hostname}</span></td>
</tr>
<tr> </tr>
<tr>
<th>Configuration Description</th>
<td><span id="cdesc"><%= request.getParameter("cfgdesc") %></span></td>
<th width="25%">Os Name</th>
<td width="25%"><span id="cosname">{osname}</span></td>
</tr>
<tr>
<th>Configuration Type</th>
<td><span id="ctype"><%= request.getParameter("cfgtype") %></span></td>
<th>Product Name</th>
<td><span id="cproductname"></span></td>
</tr>
<tr>
<th>Last Updated Time</th>
<td><span id="clastupdatetime"></span></td>
<th>Configuration File Name</th>
<td><span id="cfilename"><%= request.getParameter("filepath") %></span></td>
</tr>
</tbody>
</table>
Оба ваших ответа (Kees и Mick) помогли мне
Я сделал $.get("content.jsp?cfgname=<%= request.getParameter("cfgname") %>", addContent);
, который решил мою проблему. Спасибо, ребята