java技術博客

          jsp博客
          <2008年10月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統計

          • 隨筆 - 84
          • 文章 - 1
          • 評論 - 2
          • 引用 - 0

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          jsp中使用類



          package mypack;
          class Student 
          {
              
          private int age;
              
          private String xm;
              
          private float mark;
              
          public void setAge(int age){
                  
          this.age=age;
                  }

                  
          public int getAge(){
                  
          return age;
                  }

                  
          public void setXm(String xm)
              
          {
                  
          this.xm=xm;
                  }

                  
          public String getXm()
              
          {
                  
          return xm;
                  }

                  
          public void setMark(float mark)
              
          {
                  
          this.mark=mark;
                  }

                  
          public float getMark(){
                  
          return mark;
                  }

                  

          }



          package mypack;
          class Say 
          {
              
          public String hello(String xm) 
              
          {return "Hello World "+xm;
              }

          }






          <%@page language="java" import ="java.util.*,mypack.*" pageEncoding="GBK"%>
             <%@import="....."%>//用于多個包的導入
          <%!
          public int add(int x,int y)
          {
          return x+y;
          }

          int a=10;

          %>


          <%
          Student stu
          =new Student();
          stu.setAge(
          29);
          stu.setXm(
          "guoxinghua");
          stu.setMark(
          200.0F);
          int a=100;
          %>
          <%Say s=new Say()%>
          <%=s.hello(stu.getXm())%>
          <%=s.add(10,20)%><%=stu.getAge()%>
          <%=stu.getXm()%>
          <%=stu.getMark()%>
          <%=this.a%>
          <%=a%>

          <%%>這種是代碼段,在這里聲明的方法和變量是在局部的
          <%!%>這種是聲明語句,在這里聲明的變量和方法是全局的
           <%=%>這種是表達式

          posted on 2008-10-25 11:55 郭興華 閱讀(236) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 土默特右旗| 眉山市| 左云县| 梅河口市| 喀喇| 丹巴县| 渑池县| 花莲市| 渝北区| 高碑店市| 新乡市| 永仁县| 金平| 宁强县| 仪陇县| 应城市| 信丰县| 江都市| 深泽县| 谢通门县| 南溪县| 武义县| 湾仔区| 墨竹工卡县| 巫山县| 浑源县| 新田县| 西宁市| 孙吴县| 潮州市| 缙云县| 县级市| 成安县| 景德镇市| 日喀则市| 吴旗县| 都安| 宜川县| 札达县| 北宁市| 泰顺县|