page指令,include指令script的使用

Jsp基础语法

1.      Script的使用

2.      page指令的使用

3.      包含指令的使用

第一种Script:<%%>,可以定义局部变量,编写语句

<%

   /*

   int x=10;

   String info="www.mldn";

  out.println("<h2>x="+x+"</h2>");

   out.println("<h2>info="+info+"</h2>");

    */

%>

第二种Script:

<%!

      public static final String INFO="www.MLDN";

    %>

    <%!

    public int add(int x,int y){

    return x+y;

    }

     %>

     <%!

     class Person{

     private String name;

     private int age;

     public Person(String name,int age){

     this.name=name;

     this.age=age;

     }

     public String toString()

     {

       return "name="+this.name+";age="+this.age;

     }

     }

    

      %>

    <%

      out.println("<h3>INFO="+INFO+"</h3>");

      out.println("<h3>3+5="+add(3,5)+"</h3>");

      out.println("<h3>"+new Person("zhangsan",30)+"</h3>");

     %>

第三种Script:

<%

Stringinfo="www.mldn";

int temp=30;

%>

<h3>info=<%=info %></h3>

<h3>temp=<%=temp %></h3>

<h3>name=<%="LiXiaoLong" %></h3><%--输出常量 --%>

4.    page指令;

<%@ page language="java"import="java.util.*" contentType="text/html;charset=GBK"%>

使用word打开:

<%@ page language="java"import="java.util.*" contentType="application/msword; charset=GBK"%>

5.      包含指令的使用:

<%@ include file="index.jsp" %>

  <jsp:include page="index.jsp"/>

  <jsp:include page="a.jsp">

  <jsp:param value="asd"name="name"/>

  <jsp:param value="des"name="info"/>

  </jsp:include>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值