熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

JSP中bean的使用

2022-06-13   來源: JSP教程 

   

package beanpackage;

/**
 *
 * @author lucifer
 */ 
public class SystemPRoperties {
     public String getRuntimeEnvironmentVersion(){
          return SystemgetProperty("javaversion");
     }
     public String getRuntimeEnvironmentVendor(){
          return SystemgetProperty("javavendor");
     }

     public String getVmVersion(){
          return SystemgetProperty("javavmversion");
     }
     public String getVmVendor(){
          return SystemgetProperty("javavmvendor");
     }
     public String getVmName(){
          return SystemgetProperty("javavmname");
     }

     public String getVmSpecVersion(){
          return SystemgetProperty("javavmspecificationversion");
     }
     public String getVmSpecVendor(){
          return SystemgetProperty("javavmspecificationvendor");
     }
     public String getVmSpecName(){
          return SystemgetProperty("javavmspecificationname");
     } 

     public String getRteSpecName(){
          return SystemgetProperty("javaspecificationname");
     }
     public String getRteSpecVersion(){
          return SystemgetProperty("javaspecificationversion");
     }
     public String getRteSpecVendor(){
          return SystemgetProperty("javaspecificationvendor");
     } 

     public String getOperatingSystemName(){
          return SystemgetProperty("osname");
     }
     public String getOperatingSystemVersion(){
          return SystemgetProperty("osversion");
     }
     public String getOperatingSystemArchitecture(){
          return SystemgetProperty("osarch");
     }
}  

  
jsp代碼 

<% 
    Document   : usebean
    Created on :  ::
    Author     : lucifer
%>

<%@page contentType="text/html" pageEncoding="UTF"%>
<!DOCTYPE HTML PUBLIC "//WC//DTD HTML  Transitional//EN"
   "
<jsp:useBean id="properties" class="beanpackageSystemProperties"/>
<html>
    <head>
        <meta httpequiv="ContentType" content="text/html; charset=UTF">
        <title>JSP Page</title>
    </head>
    <body>
         Operating System Name:
         <jsp:getProperty name="properties" property="operatingSystemName"/>
         <br>
         Operating System Version:
         <jsp:getProperty name="properties" property="operatingSystemVersion"/>
         <br>
         Operating System Architecture:
         <jsp:getProperty name="properties" property="operatingSystemArchitecture"/>
         <br>
         <br>
         Runtime Environment Version(JDK version):
         <jsp:getProperty name="properties" property="runtimeEnvironmentVersion"/>
         <br>
         Runtime Environment Vendor(JDK vendor):
         <jsp:getProperty name="properties" property="runtimeEnvironmentVendor"/>
         <br>
         <br>
         VM Version:
         <jsp:getProperty name="properties" property="vmVersion"/>
         <br>
         VM Vendor:
         <jsp:getProperty name="properties" property="vmVendor"/>
         <br>
         VM Name:
         <jsp:getProperty name="properties" property="vmName"/>
         <br>
         <br>
         RTE Specification Version:
         <jsp:getProperty name="properties" property="rteSpecVersion"/>
         <br>
         RTE Specification Vendor:
         <jsp:getProperty name="properties" property="rteSpecVendor"/>
         <br>
         RTE Specification Name:
         <jsp:getProperty name="properties" property="rteSpecName"/>
         <br>
         <br>
         VM Specification Name:
         <jsp:getProperty name="properties" property="vmSpecName"/>
         <br>
         VM Specification Version:
         <jsp:getProperty name="properties" property="vmSpecVersion"/>
         <br>
         VM Specification Vendor:
         <jsp:getProperty name="properties" property="vmSpecVendor"/>
    </body>
</html>  

  輸出 

Operating System Name: Windows Vista 
Operating System Version:  
Operating System Architecture: x 

Runtime Environment Version(JDK version): _ 
Runtime Environment Vendor(JDK vendor): Sun Microsystems Inc 

VM Version: b 
VM Vendor: Sun Microsystems Inc 
VM Name: Java HotSpot(TM) Client VM 

RTE Specification Version:  
RTE Specification Vendor: Sun Microsystems Inc 
RTE Specification Name: Java Platform API Specification 

VM Specification Name: Java Virtual Machine Specification 
VM Specification Version:  
VM Specification Vendor: Sun Microsystems Inc 


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20116.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.