Topic: 使用<jsp:forward>的问题

  Print this page

1.使用<jsp:forward>的问题 Copy to clipboard
Posted by: shokey520
Posted on: 2006-10-29 01:56

我本来打算实现这样一个功能,如查看书籍时,如果没有查询数据库没有书籍就转向添加书籍的界面。思路是在viewBook.jsp中判断,然后弹出一个提示框,再转向addBook.jsp。但是我发现直接就转向了addBook.jsp,并没有给出提示框。下面给出一个测试弹出对话框后转向的部分代码:
<script language="javascript">
alert("当前页面是test.jsp\n测试跳转功能\n跳转到index.jsp");  
</script>
<jsp:forward page="test2.jsp">
结果发现根本没有弹出对话框就跳转了。请问需要如何改进才能达到我要的效果。

2.Re:使用<jsp:forward>的问题 [Re: shokey520] Copy to clipboard
Posted by: lisliefor
Posted on: 2006-10-29 10:07

Logic problem ! JavaScript is based on the response of event and you don't link to any events.
Why don't you get another way :
If you search nothing , you can enter to a new jsp-page and just show the message , then this page will close in 3 seconds and link to addBook.jsp.
else you link to test2.jsp.

I think you want to test the tag <jsp:forward> , so my answer do not solve your problem but we never use the tag in the development of software in most case.

3.Re:使用<jsp:forward>的问题 [Re: shokey520] Copy to clipboard
Posted by: shokey520
Posted on: 2006-10-29 14:11

谢谢答复。我主要是想弄清楚,为什么<jsp:forward>前面的内容没有反应。在网上搜索后,说是<jsp:forward>前面的内容不输出,需要强制输出。当我使用out.flush()强制输出后,<jsp:forward>又不执行了。所以很是疑惑。

4.Re:使用<jsp:forward>的问题 [Re: shokey520] Copy to clipboard
Posted by:
Posted on: 2006-11-01 23:28

<jsp:forward 是服务器端,javascript是客户端,服务器的比客户端的快


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923