最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > jsp教程

jsp开发:JSP中forward用法

日期:10-15    来源:中国设计秀    作者:cnwebshow.com

1.首页(填写姓名)(可选,表单post到time.jsp即可):7Um中国设计秀

7Um中国设计秀

2.判断时间forward到不同页面:7Um中国设计秀

time.jsp:7Um中国设计秀

<%-- 7Um中国设计秀
    Document   : index7Um中国设计秀
    Created on : 2009-10-3, 15:48:007Um中国设计秀
    Author     : lucifer7Um中国设计秀
--%>7Um中国设计秀

<%@page contentType="text/html" pageEncoding="UTF-8"%>7Um中国设计秀
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"7Um中国设计秀
   "http://www.w3.org/TR/html4/loose.dtd">7Um中国设计秀
<%@page import="java.util.Date" %>7Um中国设计秀
<html>7Um中国设计秀
    <head>7Um中国设计秀
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">7Um中国设计秀
        <title>JSP Page</title>7Um中国设计秀
    </head>7Um中国设计秀
    <body>7Um中国设计秀
        <%7Um中国设计秀
               Date dat =7Um中国设计秀
                       new Date();7Um中国设计秀
               if(dat.getHours() <= 12){7Um中国设计秀
                    %>7Um中国设计秀
                    <jsp:forward page="AmGreeting.jsp"/>7Um中国设计秀
         <%}7Um中国设计秀
               else{7Um中国设计秀
                    %>7Um中国设计秀
                    <jsp:forward page="PmGreeting.jsp"/>7Um中国设计秀
                    <%}7Um中国设计秀
         %>7Um中国设计秀
    </body>7Um中国设计秀
</html>7Um中国设计秀

3.如果是早上:7Um中国设计秀

AmGreeting.jsp:7Um中国设计秀

<%-- 7Um中国设计秀
    Document   : AmGreeting7Um中国设计秀
    Created on : 2009-10-3, 16:00:107Um中国设计秀
    Author     : lucifer7Um中国设计秀
--%>7Um中国设计秀

<%@page contentType="text/html" pageEncoding="UTF-8"%>7Um中国设计秀
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"7Um中国设计秀
   "http://www.w3.org/TR/html4/loose.dtd">7Um中国设计秀

<html>7Um中国设计秀
    <head>7Um中国设计秀
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">7Um中国设计秀
        <title>JSP Page</title>7Um中国设计秀
    </head>7Um中国设计秀
    <body>7Um中国设计秀
        <h1>Good Morning! </h1>7Um中国设计秀
        <%7Um中国设计秀
               String name = request.getParameter("userName");7Um中国设计秀
               out.PRintln(name);7Um中国设计秀
         %>7Um中国设计秀
         !!!7Um中国设计秀
    </body>7Um中国设计秀
</html>7Um中国设计秀

如果是下午:7Um中国设计秀

PmGreeting.jsp:7Um中国设计秀

<%--7Um中国设计秀
    Document   : AmGreeting7Um中国设计秀
    Created on : 2009-10-3, 16:00:107Um中国设计秀
    Author     : lucifer7Um中国设计秀
--%>7Um中国设计秀

<%@page contentType="text/html" pageEncoding="UTF-8"%>7Um中国设计秀
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"7Um中国设计秀
   "http://www.w3.org/TR/html4/loose.dtd">7Um中国设计秀

<html>7Um中国设计秀
    <head>7Um中国设计秀
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">7Um中国设计秀
        <title>JSP Page</title>7Um中国设计秀
    </head>7Um中国设计秀
    <body>7Um中国设计秀
        <h1>Good Afternoon! </h1>7Um中国设计秀
        <%7Um中国设计秀
               String name = request.getParameter("userName");7Um中国设计秀
               out.println(name);7Um中国设计秀
         %>7Um中国设计秀
         !!!7Um中国设计秀
    </body>7Um中国设计秀
</html>7Um中国设计秀

本文引用地址:/bc/article_46558.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明