日期:2014-05-18  浏览次数:20661 次

jsp中传id值弹出新窗口显示详细信息的问题,有高分相谢!
是这样的,我jsp页面中显示了一张表的内容。我现在要点其中一条记录,把id值传到action中去,然后得到这条记录的详细信息,然后弹出一个新窗口,让详细在新窗口中显示。
让以前那个jsp页面不刷新,弹出窗口来显示,这样能做到吗?
window.open()?用js代码该怎么写?
谢谢朋友们的帮忙!

------解决方案--------------------
var url = "xxx.jsp?id= " + id;
window.open(url);
------解决方案--------------------
类似
function systemMod(innoid)
{
ReturnValue=showModalDialog( "/test/iframetest1.jsp?URL=/test.do?method=testMod&passid= "+innoid, " ", "dialogWidth:750px; dialogHeight:550px; status:0;help:0 ");
if(ReturnValue== "yes ")
{
window.location.reload();
}
}
------解决方案--------------------
上面有问题,BS自己下,呵呵没test,JS error,不好意思。加单引号就Ok了

<a href= "# " onclick= "javascript:view( ' <%=flithId.getHbh()%> ') "> <%=flithId.getHbh()%> </a>


------解决方案--------------------
不需要用js。

大概写了个最简单的例子:

<%@ page language= "java " import= "java.util.* " pageEncoding= "ISO-8859-1 "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'a.jsp ' starting page </title>
</head>
<body>
<a href= "servlet?id=1 " target= "_blank "> aaa </a>
</body>
</html>

-----------------------

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class aaa extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute( "id ", request.getParameter( "id "));
//然后根据得到的id查询数据库中该记录的详细信息
//这里我把id传递给了c.jsp
request.getRequestDispatcher( "c.jsp ").forward(request, response);
}
}

----------------------------

<%@ page language= "java " import= "java.util.* " pageEncoding= "ISO-8859-1 "%>
<%@taglib uri= "http://java.sun.com/jsp/jstl/core " prefix= "c " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'a.jsp ' starting page </title>
</head>
<body>
id: <%=request.getAttribute( "id ") %>
</body>
</html>

c.jsp输出:
id:1

lz把Servlet改为Action就可以了。