zoukankan      html  css  js  c++  java
  • 动作元素

    动态包含:包含的是对方的输出结果,分别解释为不同的servlet。

    动态包含实例:

    (1)header.jsp:

    
        <%String text = request.getParameter( "text" );%>
    
        <center>
    
            <h1>        
    
            <font color="blue">
    
             <%if( text != null ){ %>                   
    
                <h1><%=text%></h1>
    
             <%}else{ %>
    
                <h1>Welcome to kettas</h1>
    
             <%} %>
    
            </font>
    
            </h1>   
    
        </center>
    

    (2) body.jsp :

    
        <%@page contentType="text/html" %>
    
            <html> 
    
            <body> 
    
    <!-- 相当于<jsp:include page="/header.jsp?name=This is param"/> -->                    
    
        <jsp:include page="/header.jsp">
    
            <jsp:param name="text" value="This is param"/>
    
                </jsp:include>  
    
                <h1>This is body</h1> 
    
                <% 
    
                    for(int i = 0 ; i< 3 ; i++ ){
    
                %>
    
                <h2><%= new java.util.Date() %></h2> 
    
                <%
    
                    }
    
                %>                    
    
                <%
    
                    for( int i =0 ; i < 3 ; i++ ){
    
                        out.println( "<h2>" + new java.util.Date() + "</h2>" ) ;
    
                    }
    
                %>
    
                </body>
    
            </html> 
    
        <jsp:forward page="/b.jsp" />
    
            页面转向 : 相当于servlet中的"接力棒"转向, 是在同一个连接中的页面转向.
    
        <% response.sendRedirect("/a.jsp"); %>
    

    页面转向:连接已经换了一个。

  • 相关阅读:
    Spring配置数据源和注解开发
    spring 的配置介绍
    spring
    maven
    mybatis初始
    idea中配置xml不自动提示解决方案(eclipse配置XmlCatalog)
    JSON、AJAX
    ThreadLocal的使用
    Filter过滤器
    谷歌 kaptcha 图片验证码的使用
  • 原文地址:https://www.cnblogs.com/yuyu666/p/9743835.html
Copyright © 2011-2022 走看看