zoukankan      html  css  js  c++  java
  • JSP | 基础 | JSP行为 | incline && forward

    语法描述
    jsp:include

    用于在当前页面中包含静态或动态资源

    jsp:forward

    从一个JSP文件向另一个文件传递一个包含用户请求的request对象

     index.jsp

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    	String side = request.getParameter("side");
    	if(side == null) {
    %>
    	<jsp:forward page="index.jsp">
    		<jsp:param name="side" value="10"/>
    	</jsp:forward>
    <%
    	}
    	int l = Integer.parseInt(side);
    %>
    <h3>实验三:计算立方</h3>
    <jsp:include page="page1.jsp">
    	<jsp:param name="side" value="<%=l %>" />
    </jsp:include>
    </body>
    </html>
    

      

    page1.jsp

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    	String side = request.getParameter("side");
    	int l = Integer.parseInt(side);
    %>
    
    <%=side %>的立方是:
    <%= l*l*l %>
    </body>
    </html>
    

      

  • 相关阅读:
    计算机网络协议如何学习之换位思考
    tcp/ip协议
    JSP页面中的元素
    动态网页脚本语言
    php的学习经验
    jsp、php和asp之间的区别
    Reactor 线程模型
    Hadoop集群搭建
    hadoop单点配置
    Docker 安装脚本
  • 原文地址:https://www.cnblogs.com/jj81/p/9698343.html
Copyright © 2011-2022 走看看